[英]JavaScript - Gulp/Browserify: SyntaxError: Unexpected token
For whatever reason, my browserify
and gulp
stopped working. 无论出于何种原因,我的
browserify
和gulp
停止了工作。 For example, here's my gulp js
script to bundle my javascript. 例如,这是我的
gulp js
脚本捆绑我的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
: 这是
main.js
:
var ajaxChng = require('./ajax-changelog');
ajaxChng();
and inside src/js/ajax-changelog.js
is this: 在
src/js/ajax-changelog.js
是这样的:
module.exports = {
console.log('Hello World');
};
But when I do gulp js
, I get: 但当我做
gulp js
,我得到:
λ 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: 等等......这是无效的javascript:
module.exports = {
console.log('Hello World');
};
Maybe you meant this? 也许你是这个意思?
module.exports = function () {
console.log('Hello World');
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.