gpt4 book ai didi

javascript - 使用npm模块进行前端依赖失败

转载 作者:太空宇宙 更新时间:2023-11-04 00:38:44 24 4
gpt4 key购买 nike

我以为我可以做 npm 而不是 Bower,我所做的是 npm install angular --save ,然后像这样包含它

<script src="../node_modules/angular/angular.js"></script>

但路径似乎不正确。我创建一个临时存储库来展示我的文件夹结构。

https://github.com/eldyvoon/temp/

最佳答案

为了使用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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com