【发布时间】:2014-05-08 18:39:03
【问题描述】:
因此,有了this tutorial,我决定在我的 node.js 应用程序中添加一些单元测试。我的 gruntfile 似乎没问题,当我输入 grunt nodeunit 时,我唯一的测试运行得很好,但在那之后,它崩溃并出现错误 Fatal error: Cannot find module 'tap':
$> grunt nodeunit
Running "nodeunit:all" (nodeunit) task
Testing db.test.js
.OK
Fatal error: Cannot find module 'tap'
我对这个模块一无所知,但是在谷歌搜索之后,它似乎是 nodeunit 需要的东西。确实,它在那里:$MY_NODE_APP/node_modules/nodeunit/node_modules/tap 存在,当我在$MY_NODE_APP/node_modules/nodeunit 中启动节点并在交互式控制台中输入require('tap') 时,我得到了一些包含很多东西的对象,这给我的印象是它应该可以正常工作.
那么,显而易见的问题是:为什么会出现此错误,我该如何解决?
Gruntfile:
module.exports = function(grunt) {
grunt.initConfig({
nodeunit: {
all: ['./**/*.test.js']
}
});
grunt.loadNpmTasks('grunt-contrib-nodeunit');
};
更新:在我的项目中安装了tap,但也没有帮助。
【问题讨论】:
-
由于“信息不足”,我获得了一张接近投票。我应该在问题中添加哪些信息?
标签: node.js requirejs gruntjs npm nodeunit