javascript -/bower_components 不加载页面上的依赖项

标签 javascript jquery node.js bower

/bower_components 不起作用。

我收到 404 错误:

GET /bower_components/jquery/jquery.js 404

我的配置如 Bower 文档和 here 中所述:

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

在我的 .html 文件中我有:

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

但是没有/bower_components/jquery/jquery.js。有 \bower_components\jquery\dist\jquery.js。他们是否更改了 Bower 包的配置但忘记更改文档?

最佳答案

您应该更改您的脚本标记以指向 jQuery 的(新)位置:

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

看起来 jQuery 通过在其 bower 组件中提供两个目录,将“源”代码与“分发”代码分开。不建议您在 bower_components 中移动内容,因为该目录是从 bower 安装生成的。

关于javascript -/bower_components 不加载页面上的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23933621/

相关文章:

javascript - Js 文件加载不正确

Node.js util Promisify Mongoose 方法

javascript - Sequelize 仅在子表中插入(关联 : belongsTo)

javascript - 面对动态数据的 ng-init 问题

javascript - 在 Node-js 中处理 HTML 事件

javascript - 如何将数据从客户端传输到服务器(静默)?

javascript - ajax 将数据从客户端(js)发送到服务器(php)

php - 如何检测浏览器/选项卡是否关闭

jquery - 通过 data 属性选择通过 Ajax 加载的元素

javascript - Scraper 不使用 Cheerio 使用 jquery 返回任何值