Node.js browserify watchify产生错误
我正在使用gulp、browserify和watchify。以下是我的“脚本”任务:Node.js browserify watchify产生错误,node.js,gulp,browserify,node-request,Node.js,Gulp,Browserify,Node Request,我正在使用gulp、browserify和watchify。以下是我的“脚本”任务: gulp.task('scripts', function() { var b = watchify(browserify(paths.app.root + '/client.js', watchify.args)); b.on('update', bundle); return bundle(); function bundle() { return
gulp.task('scripts', function() {
var b = watchify(browserify(paths.app.root + '/client.js', watchify.args));
b.on('update', bundle);
return bundle();
function bundle() {
return b
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest(paths.build.root + '/scripts'));
}
});
client.js
看起来像:
require('request');
alert('1');
其中,请求
是节点模块(http客户端):
当我运行这个任务并执行代码时,一切都很好。当我更改client.js
时,问题就开始了。当我评论alert('1')
时,watchify开始工作,并再次运行bundle()
。在浏览器上重新加载页面时,会出现以下javascript异常:
Uncaught TypeError: Cannot read property 'version' of undefined
使用以下堆栈跟踪:
/Users/me/project/node_modules/browserify/node_modules/crypto-browserify/node_modules/browserify-sign/node_modules/elliptic/lib/elliptic.js.../package.jsonbundle.js:19825
/Users/me/project/node_modules/browserify/node_modules/crypto-browserify/node_modules/create-ecdh/node_modules/elliptic/lib/elliptic.js.../package.jsonbundle.js:1
/Users/me/project/node_modules/browserify/node_modules/crypto-browserify/node_modules/create-ecdh/ecdh.js.bn.js
/Users/me/project/node_modules/browserify/node_modules/crypto-browserify/node_modules/create-ecdh/inject.js../ecdh
/Users/me/project/node_modules/browserify/node_modules/crypto-browserify/index.js.browserify-aes
/Users/me/project/node_modules/request/lib/helpers.js._process
/Users/me/project/node_modules/request/index.js../lib/cookies
./client.js.request
你知道browserify/request有什么问题吗?看起来这是一个与椭圆相关的问题,椭圆是browserify的一个依赖项。看 希望这个问题很快得到解决 编辑:这实际上可能是browserify的问题。我会尝试返回到8.1.2,看看这是否有帮助