简体   繁体   English

/ bower_components不会在页面上加载依赖项

[英]/bower_components doesn’t load dependencies on the page

/bower_components doesn't work. /bower_components不起作用。

I get 404 error: 我收到404错误:

GET /bower_components/jquery/jquery.js 404

My configuration is as described in Bower documentation and here : 我的配置如Bower文档中所述, 此处

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

In my .html file I have: 在我的.html文件中,我有:

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

But there is no /bower_components/jquery/jquery.js . 但是没有/bower_components/jquery/jquery.js There is \\bower_components\\jquery\\dist\\jquery.js . \\bower_components\\jquery\\dist\\jquery.js Did they change the configuration of Bower packages but forgot to change docs? 他们是否更改了Bower套餐的配置但忘记更改文档?

You should change your script tag to point to the (new) location of jQuery: 您应该将脚本标记更改为指向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. 看起来jQuery通过在其凉亭组件中提供两个目录,将“源”代码与“分发”代码分开。 It is not recommended that you move things around inside bower_components since that directory is generated from the bower install. 不建议您在bower_components移动内容,因为该目录是从bower安装生成的。

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 在我的情况下,我不小心删除了.bowerrc,导致bower_components被保存在错误的地方

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM