我是node的新手,正在尝试按照本教程使用gulp设置browserify:https://www.learnhowtoprogram.com/javascript/introduction-to-javascript/using-browserify-with-gulp。请帮帮我,我已经用谷歌搜索过了,没有解决办法。
我的gulp文件显示:
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
gulp.task('jsBrowserify', function() {
return browserify({ entries: ['./js/pingpong-interface.js'] })
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./build/js'));
});我跑进了终端:
gulp jsBrowserify这应该会创建“build”文件夹。
相反,我得到的是错误:
C:\Users\danrusu\Documents\Coding Docs\projects\pingpong>gulp jsBrowserify
(node:7728) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[11:04:15] Using gulpfile ~\Documents\Coding Docs\projects\pingpong\gulpfile.js
[11:04:15] Starting 'jsBrowserify'...
events.js:160
throw er; // Unhandled 'error' event
^
SyntaxError: Unexpected token发布于 2016-08-04 03:04:27
即使没有错误,browserify调用也需要一个.on('error', callback)管道来捕获错误。通常,我会这样定义:
function handleError(message){
// print the message to console
}然后可以这样做:
return browserify({...})
.on('error', handleError)
.pipe(...)
...我可能有确切的语法错误,但您可以很容易地通过browserify的文档找到它所需的确切语法和调用。
https://stackoverflow.com/questions/38751545
复制相似问题