JavaScript - Gulp/Browserify: SyntaxError: Unexpected token -
for whatever reason, browserify
, gulp
stopped working. example, here's gulp js
script bundle 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 browserify!'})); // .pipe(livereload()); });
and here main.js
:
var ajaxchng = require('./ajax-changelog'); ajaxchng();
and inside src/js/ajax-changelog.js
this:
module.exports = { console.log('hello world'); };
but when gulp js
, 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
... doing wrong?
wait... not valid javascript:
module.exports = { console.log('hello world'); };
maybe meant this?
module.exports = function () { console.log('hello world'); };
Comments
Post a Comment