找不到模块'./lib/should'
我有一个testing代码,并试图运行它
var should = require("should") describe('Array', function(){ describe('#indexOf()', function(){ it('should return -1 when the value is not present',function(){ [1,2,3].indexOf(5).should.equal(-1); [1,2,3].indexOf(0).should.equal(-1); }) }) })
当我运行它我得到错误
Error: Cannot find module './lib/should' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/ritesh/projects/passport-topcoder/node_modules/should/index.js:2:18) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/ritesh/projects/passport-topcoder/test/module.test.js:1:76) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at /usr/local/lib/node_modules/mocha/lib/mocha.js:152:27 at Array.forEach (native) at Mocha.loadFiles (/usr/local/lib/node_modules/mocha/lib/mocha.js:149:14) at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:306:31) at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:348:7) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:901:3
我包括摩卡,应该在package.json,但为什么我面临这个错误。应该显示在我的节点modules.please指南
我面临同样的问题,我认为这是因为包should
在两个小时前更新(可能已经破坏了一些东西)。
npm install should@1.3.0
做的伎俩。
编辑
2.0.1版解决了这个问题。
这只是意味着should
从NPM没有安装。 简单的使用
sudo npm install should
这意味着它应该从节点包pipe理安装。
希望它能使事情更清楚。
干杯。
- 如何testing模块中的OpenCV nodejs绑定代码?
- 如何使用文件参数进行摩卡/ chaitesting?
- 使用mocha和超级testing的NodeJS HTTPS APItesting – “DEPTH_ZERO_SELF_SIGNED_CERT”
- 咕噜摩卡没有发现目标的错误
- JSDom不加载相关的脚本
- Cloud9中的Mochatesting中的“未声明的variables”警告
- 如何使用supertest和代理在摩卡testing中进行authentication请求?
- validation使用Mocha / Chai和asynchronous/等待引发exception
- closuresOpenLink Virtuoso HTTP连接