小编典典

从gulp发出运行业力任务

node.js

我正在尝试从gulp任务运行业力测试,但出现此错误:

Error: 1
   at formatError (C:\Users\Tim\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:161:10)
   at Gulp.<anonymous> (C:\Users\Tim\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:187:15)
   at Gulp.emit (events.js:95:17)
   at Gulp.Orchestrator._emitTaskDone (C:\path\to\project\node_modules\gulp\node_modules\orchestrator\index.js:264:8)
   at C:\path\to\project\node_modules\gulp\node_modules\orchestrator\index.js:275:23
   at finish (C:\path\to\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:21:8)
   at cb (C:\path\to\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:29:3)
   at removeAllListeners (C:\path\to\project\node_modules\karma\lib\server.js:216:7)
   at Server.<anonymous> (C:\path\to\project\node_modules\karma\lib\server.js:227:9)
   at Server.g (events.js:180:16)

我的系统是Windows 7,nodejs版本是,gulp v0.10.32版本:

[10:26:52] CLI version 3.8.8
[10:26:52] Local version 3.8.9

另外,Ubuntu 12.04 LTS在较新的Ubuntu(不确定哪个版本)和Mac OS上遇到的相同错误似乎也可以。什么会导致此错误?

2016年5月11日更新
:在写关于接受的答案隐藏错误这一事实的评论之前,请先查看该特定接受的答案的前两个评论。仅当知道您在做什么时才使用它。相关信息:https : //github.com/karma-runner/gulp-
karma/pull/15


阅读 244

收藏
2020-07-07

共1个答案

小编典典

您如何使用Gulp进行测试?每当测试失败时,我最近在OSX上都遇到了这个问题,运行node v0.11.14和gulp 3.8.10

从建议的更改:

gulp.task('test', function(done) {
    karma.start({
        configFile: __dirname + '/karma.conf.js',
        singleRun: true
    }, done);
});

至:

gulp.task('test', function(done) {
    karma.start({
        configFile: __dirname + '/karma.conf.js',
        singleRun: true
    }, function() {
        done();
    });
});

…摆脱了这个错误。

似乎取决于在回调中发出错误信号时,gulp如何处理错误消息。有关更多信息,请参见改进退出时的错误消息

2020-07-07