I wonder how you work with the npm as a package manager in a project?
My project uses the following file structure:
.
|_ site/
| |_ bower_components/
| |_ index.html
| |_ assets/
| |_ js/
| |_ scripts.js
|
|_ dist/
|_ node_modules/
| |_ underscore
| |_ underscore-min.js
|
|_ gulpfile.js
|_ package.json
|_ ...
I use this gulp task for serving / browser refresh:
gulp.task('serve', function () {
browserSync.init({
server: {
baseDir: ['site']
},
notify: false
});
gulp.watch(['site/**/*.html'], reload);
gulp.watch(['site/assets/css/**/*.css'], ['styles', reload]);
gulp.watch(['site/assets/images/**/*'], ['images']);
});
Now when I want to include scripts from my node_modules folder (for example underscore) I would do this:
<script src="../node_modules/underscore/underscore-min.js"></script>
However this will give me a 404 File not found on the underscore-min.js file but the path is correct? In the "gulp serve task" the base directory is set to "site" so I guess I can't go one folder up with "../"?
I can not tell npm to save its modules in a different folder. Also the project structure seems to me pretty common so I wonder how would someone setup a project to work with the packages.
How would a workflow look like when using npm install somePackage? Do you copy it out of the node_modules inside to your projects folder (e.g. assets/js/..).