我正在try 从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版本是v0.10.32,gulp版本:

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

此外,在更新的Ubuntu(不确定是什么版本)和mac os上,我在Ubuntu 12.04 LTS上遇到了同样的错误,它似乎工作正常.什么会导致这个错误?

Update 5/11/2016:在对接受答案隐藏错误这一事实发表 comments 之前,请参阅对该特定接受答案的前两条 comments .只有当你知道自己在做什么时才使用它.相关信息:https://github.com/karma-runner/gulp-karma/pull/15

推荐答案

你是如何用大口大口大口地进行测试的?我最近在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在回调中发出错误信号时如何处理错误消息.更多信息请参见Improve error messages on exit.

Node.js相关问答推荐

GitLab SAST中的Nodejcan未找到匹配项

购物车是空的状态|本地存储不更新产品数量|Redux|

在内存中加载安全密钥安全吗?还是每次都从文件中读取?

Playwright - 无法在 img 标签中使用 file:// 访问本地文件

DynamoDB 分页数据检索

Node.js 上的 CLI 应用程序如何通过 child_process 将选项值作为参数传递给 Shell 命令

如何解决 npm install react-select failure with error : An unknown git error occurred, git@github.com :Permission denied (publickey)

强制 TypeScript 生成带有.js扩展名的导出/导入;运行 node 16?

类 WebSwapCGLLayer 在 Mac OS X /System 和 node_modules 中都实现了

如何promise AWS JavaScript 开发工具包?

通过 npm 导入 Sass

提供静态文件到底是什么意思?

如何使用适用于 Node.js 的 AWS 开发工具包将 Amazon S3 中的所有对象从一个前缀复制/移动到另一个前缀

使用 nvm-windows 时更新 npm

在 Node.js 中的两个不同进程之间进行通信

Node.js:socket.io 关闭客户端连接

异步构造函数

将 Heroku App 连接到 Atlas MongoDB 云服务

Node.js - 判断是否安装了模块而不实际需要它

为什么 Node.js 被命名为 Node.js?