I try to create a basic assembly using Gulp and scroll the browser, but I continue to see this error when I try to start the default task:
Error: Cannot find module 'src/js/main.js' from '/Users/ben/dev/git/myapp/'
gulpfile.js
var gulp = require('gulp'); var browserify = require('browserify'); var del = require('del'); var source = require('vinyl-source-stream'); var paths = { main_js: ['src/js/main.js'], js: ['src/js/*.js'] }; gulp.task('clean', function(done) { del(['build'], done); }); gulp.task('js', ['clean'], function() { browserify(paths.main_js) .bundle() .pipe(source('bundle.js')) .pipe(gulp.dest('./build/')); }); gulp.task('watch', function() { gulp.watch(paths.js, ['js']); }); gulp.task('default', ['watch', 'js']);
main.js
console.log("Hello!")
MYAPP /
. ├── gulpfile.js ├── node_modules │ ├── browserify │ ├── del │ ├── gulp │ └── vinyl-source-stream ├── npm-debug.log ├── package.json └── src ├── css ├── index.html └── js └── main.js
I cannot understand why it does not find main.js. When I run this command from myapp/
, it works fine:
$ browserify src/js/main.js > build/bundle.js
source share