我以为我可以做 npm 而不是 Bower,我所做的是 npm install angular --save
,然后像这样包含它
<script src="../node_modules/angular/angular.js"></script>
但路径似乎不正确。我创建一个临时存储库来展示我的文件夹结构。
最佳答案
为了使用node_modules,您必须使用browsersync公开目录。
尝试一下,像这样更改 gulfile.js 中的浏览器同步 gulp 任务:
gulp.task('browser-sync', function() {
browserSync.init(null, {
server: {
baseDir: 'app',
routes: {
'/node_modules': './node_modules'
}
}
});
});
在你的index.html中你的jquery导入是错误的,使用这个:
<script src="../node_modules/jquery/dist/jquery.min.js"></script>
希望这有帮助,如果您需要更多信息,请告诉我
关于javascript - 使用npm模块进行前端依赖失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37783699/