试图让摩卡看我的项目时,“没有这样的模块”错误
我试图让摩卡看我的项目进行testing,并不断运行testing,但是当我使用-w
标志,我得到一个错误。
这里的testing执行得很好:
C:\Foo>mocha . ? 1 tests complete (3ms)
这里用-w
C:\Foo>mocha -w node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: No such module at EventEmitter.<anonymous> (node.js:392:27) at Object.<anonymous> (C:\Users\Greg\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:203:11) at Module._compile (module.js:441:26) at Object..js (module.js:459:10) at Module.load (module.js:348:31) at Function._load (module.js:308:12) at Array.0 (module.js:479:10) at EventEmitter._tickCallback (node.js:192:40)
我在全球npm install -g mocha
( npm install -g mocha
),并且应该在本地安装到项目中。
我在64位Windows 7家庭高级版上使用节点v0.6015,Mocha 1.0.1和0.6.1。
我能够通过更改一些摩卡源代码文件来使它在窗口上工作。 npm后安装摩卡(在我的情况下,我只是为我的项目,而不是全球安装):
1)首先去node_modules \ mocha \ lib \ utils.jsfind并修复watch函数,如下所示:
exports.watch = function(files, fn) { var options = { interval: 100 }; files.forEach(function(file) { debug('file %s', file); fs.watch(file, options, function(curr, prev) { fn(file); }); }); };
我将fs.watchFilereplace为fs.watch(详情请参阅https://github.com/fgnass/node-dev/issues/26 ),因为第一个窗口似乎不适用于Windows。
2)现在打开node_modules \ mocha \ bin \ _mocha并应用以下修复:
a)查找并注释掉或删除以下代码:
process.on('SIGINT', function(){ showCursor(); console.log('\n'); process.exit(); });
由于没有等效的POSIX信号线必须被删除(理想情况下,用适当的实现来取代,请参阅node.js中的process.on('SIGINT')的Windows等效内容)
b)find下面的代码utils.watch(watchFiles,function(){…)并将其replace为
var lastRun = new Date(); utils.watch(watchFiles, function(){ if (new Date() - lastRun > 300) { purge(); stop() mocha.suite = mocha.suite.clone(); ui = interfaces[program.ui](mocha.suite); loadAndRun(); lastRun = new Date(); } });
它从fs.watch扼杀了过多的callacks。
c)最后更改是删除或注释掉这一行:
process.stdout.write('\r' + str);
在函数play(arr,interval)中 。 它只是消除噪音。
尝试在您正在testing的项目中本地安装摩卡,看起来像摩卡没有find所需的模块使用。
另外我认为这也应该对你有帮助: 摩卡要求做出来。 找不到在Windows上工作的make.exe
- 为事件创buildunit testing
- 使用Gulp,Mocha,Browserify进行正确configuration,以执行服务器端testing的客户端testing
- 用Mochatesting访问内部描述块时,外部描述块中的variables是不确定的
- 引导一个摩卡testing套件
- 在WebStorm中使用supertest会产生“参数types不能分配给参数types”和“未parsing的函数或方法”
- 如何testing自己的MongoDB包装
- 摩卡js与反应js
- 使用mocha和node.js对私有函数进行unit testing
- unit testingNodeJS Promise里面的一个函数