JavaScript-Gulp/Browserify:SyntaxError:意外的令牌
JavaScript - Gulp/Browserify: SyntaxError: Unexpected token
无论出于何种原因,我的browserify
和gulp
都停止了工作。例如,这里是我的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());
});
这里是main.js
:
var ajaxChng = require('./ajax-changelog');
ajaxChng();
src/js/ajax-changelog.js
内部是这样的:
module.exports = {
console.log('Hello World');
};
但当我做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
我做错了什么?
等待。。。这是无效的javascript:
module.exports = {
console.log('Hello World');
};
也许你是这个意思?
module.exports = function () {
console.log('Hello World');
};
相关文章:
- React JS:未捕获(在承诺中)语法错误:在位置 0 的 JSON 中意外<令牌
- 未捕获的语法错误:意外的令牌,
- jQuery$.getJSON抛出意外令牌
- 当其他解析器认为意外的令牌有效时,json.parse会失败
- 意外的令牌模块生成失败:SyntaxError
- 为什么我在下面的..of循环中得到意外令牌
- 意外的令牌非法javascript/metrol
- 三元条件中出现意外的令牌中断
- DynamoDB和Node Js:意外的令牌h
- RegEx中出现意外的令牌错误
- data.php:1未捕获的语法错误:意外的令牌:
- 错误:[$parse:syntax]语法错误:令牌''是意外的令牌
- 组件中的ReactJS意外令牌
- Jquery脚本未在运行时加载编辑:意外的令牌
- 未捕获的语法错误:意外的令牌非法?看起来不错
- "未捕获的SyntaxError:意外的令牌ILLEGAL“;当我通过AJAX发送html时
- 获取意外的令牌ILLEGAL JS错误
- JavaScript-Gulp/Browserify:SyntaxError:意外的令牌
- Jquery .ajax() SyntaxError: 意外的令牌 N.
- AngularJS $http GET 请求到本地 JSON 文件返回语法错误:意外令牌]