使用npm模块的前端依赖项失败

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

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

但似乎path是不正确的。 我创build一个临时回购来展示我的文件夹结构。

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

为了使用node_modules,你必须使用浏览器同步公开direcotry。

试试这个,像这样改变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> 

希望这有助于,让我知道如果你需要更多的信息