6

/bower_components doesn’t work.

I get 404 error:

GET /bower_components/jquery/jquery.js 404

My configuration is as described in Bower documentation and here:

app.use(express.static(path.join(__dirname, 'public')));
app.use('/bower_components',  express.static(__dirname + '/bower_components'));

In my .html file I have:

<script src="/bower_components/jquery/jquery.js"></script>

But there is no /bower_components/jquery/jquery.js. There is \bower_components\jquery\dist\jquery.js. Did they change the configuration of Bower packages but forgot to change docs?

Community
  • 1
  • 1
Green
  • 28,742
  • 61
  • 158
  • 247
  • If you look in the file system, do you see the file `/bower_components/jquery/jquery.js`? – dylants May 29 '14 at 14:25
  • @dylants: No, there is no such a path in the file system. `jquery.js` is located here: `\public\bower_components\jquery\dist\jquery.js`. I know I can move `jquery.js` and it will work but it seems that it is not correct, isn't it? – Green May 29 '14 at 15:54

2 Answers2

3

You should change your script tag to point to the (new) location of jQuery:

<script src="/bower_components/jquery/dist/jquery.js"></script>

It looks like jQuery has separated the "source" code from the "distribution" code, by providing two directories in their bower component. It is not recommended that you move things around inside bower_components since that directory is generated from the bower install.

dylants
  • 22,316
  • 3
  • 26
  • 22
0

I had the same issue. In my case, i had accidentally deleted the .bowerrc, causing the bower_components to be saved in the wrong place