For whatever reason, my browserify
and gulp
stopped working. For example, here's my gulp js
script to bundle my javascript.
gulp.task('js', function() {
gulp.src('src/js/*.js')
.pipe(plumber())
.pipe(gulp.dest('js'));
return browserify('./src/js/main', { debug: true })
.bundle()
.pipe(source('bundle.js'))
/* .pipe(streamify(uglify()))*/
.pipe(gulp.dest('.'))
.pipe(notify({ message: 'JavaScript has been bundled with Browserify!'}));
// .pipe(livereload());
});
and here is main.js
:
var ajaxChng = require('./ajax-changelog');
ajaxChng();
and inside src/js/ajax-changelog.js
is this:
module.exports = {
console.log('Hello World');
};
But when I do gulp js
, I get:
λ gulp js
[19:11:50] Using gulpfile c:\wamp\www\osrsmap\gulpfile.js
[19:11:50] Starting 'js'...
events.js:85
throw er; // Unhandled 'error' event
^
SyntaxError: Unexpected token
... what am I doing wrong?
Wait... this is not valid javascript:
module.exports = {
console.log('Hello World');
};
Maybe you meant this?
module.exports = function () {
console.log('Hello World');
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With