4

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?

2
  • What is the rest of the error? The stack trace is the most important part. Commented Mar 16, 2015 at 23:15
  • 1
    Noone noticed that the 'helpful' error context is completely wrong? That is the entire message, there's no stack to be had and the code snippet it always shows is events.js:<some line>\n throw err; // unhandled 'error' event\n ^\n SyntaxError: Unexpected token no matter what the actual source code is. Commented Jan 29, 2016 at 22:28

1 Answer 1

10

Wait... this is not valid javascript:

module.exports = { console.log('Hello World'); }; 

Maybe you meant this?

module.exports = function () { console.log('Hello World'); }; 
Sign up to request clarification or add additional context in comments.

1 Comment

I hate when this happens!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.