使用Gulp运行stubby4node时出错
我试图在我的JavaScript环境中进行设置,我得到了下面的错误 我的Gulpfile的相关部分:使用Gulp运行stubby4node时出错,gulp,Gulp,我试图在我的JavaScript环境中进行设置,我得到了下面的错误 我的Gulpfile的相关部分: gulp.task('stubby', function(cb) { var options = { callback: function (server, options) { server.get(1, function (err, endpoint) { if (!err)
gulp.task('stubby', function(cb) {
var options = {
callback: function (server, options) {
server.get(1, function (err, endpoint) {
if (!err)
console.log(endpoint);
});
},
stubs: 8000,
tls: 8443,
admin: 8010,
files: [
'*.*'
]
};
stubby(options, cb);
});
错误:
[12:15:03]正在启动“stubby”。。。
[12:15:03]“stubby”在17毫秒后出错
[12:15:03]错误:缺少错误消息
在新的PluginError(C:\Users\admin\IdeaProjects\myproject\node\u modules\gulp util\lib\PluginError.js:73:28)
在readJSON(C:\Users\admin\IdeaProjects\myproject\node\u modules\gulp stubby server\index.js:90:15)
在C:\Users\admin\IdeaProjects\myproject\node\u modules\gulp stubby server\index.js:149:24
at Array.map(本机)
在stubbyPlugin(C:\Users\admin\IdeaProjects\myproject\node\u modules\gulp stubby server\index.js:136:12)
狼吞虎咽。(C:\Users\admin\IdeaProjects\myproject\gulpfile.js:54:5)
在module.exports(C:\Users\admin\IdeaProjects\myproject\node\u modules\orchestrator\lib\runTask.js:34:7)
位于Gulp.Orchestrator.\u runTask(C:\Users\admin\IdeaProjects\myproject\node\u modules\Orchestrator\index.js:273:3)
位于Gulp.Orchestrator.\u runStep(C:\Users\admin\IdeaProjects\myproject\node\u modules\Orchestrator\index.js:214:10)
在Gulp.Orchestrator.start(C:\Users\admin\IdeaProjects\myproject\node\u modules\Orchestrator\index.js:134:8)
-
由于您看到的堆栈跟踪,PluginError
来自readJSON
,您可以看出这可能是罪魁祸首
问题
注意catch
块。这是由于与glob(*.
)匹配的文件之一不是有效的JSON文件造成的
修理
gulp stubby服务器
*.*
)谢谢Whymarh!这是我使用的GulpStubby服务器版本的一个问题。我升级到最新版本,问题得到解决。奇怪的是,我们在我的工作场所使用的是同一个版本,而且它在那里工作。
function readJSON(filepath, options) {
var src = fs.readFileSync(filepath, options),
result;
if (!options.mute) {
gutil.log(gutil.colors.yellow('Parsing ' + filepath + '...'));
}
try {
result = JSON.parse(src);
return result;
} catch (e) {
throw new gutil.PluginError(PLUGIN_NAME, 'Unable to parse "' + filepath + '" file (' + e.message + ').', e);
}
}