Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Gulp运行stubby4node时出错_Gulp - Fatal编程技术网

使用Gulp运行stubby4node时出错

使用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)

我试图在我的JavaScript环境中进行设置,我得到了下面的错误

我的Gulpfile的相关部分:

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服务器
  • 确保您使用的是正确的glob(也就是说,您的真正意思是
    *.*
  • 确保当前工作目录中的所有文件都是有效的JSON文件

  • 谢谢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);
        }
    }