2013-10-10 11 views
7

ich habe einen Test-Code und versuchen, führen Sie eskann nicht Modul './lib/should'

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); 
    }) 
    }) 
}) 

finden, wenn ich es laufen ich bin Fehler immer

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 

i Mokka enthalten und sollte in package.json, aber warum ich mit diesem Fehler konfrontiert bin. should zeigt in meinen Knoten-Modulen auch.

Antwort

7

Ich konfrontiert das gleiche Problem, und ich denke, es ist, weil should Paket vor zwei Stunden aktualisiert wurde (und es könnte etwas gebrochen haben).

npm install [email protected] 

haben den Trick gemacht.

BEARBEITEN

Version 2.0.1 behebt das Problem.

+0

vielen dank für die richtige antwort: D – Nitin

+0

gibt es auch einen fehler in 1.3.0 ?? ich stehe vor dem problem http://StackOverflow.com/questions/19303240/object-object-has-no-method-type – Nitin

+0

@Nitin Ich weiß es nicht, aber Version 2.0.1 ist online, also sollten Sie es auf jeden Fall ausprobieren! –

2

Es bedeutet einfach should aus dem NPM ist nicht installiert. Verwenden Sie einfach

sudo npm install should 

Das bedeutet, dass es should vom Knoten Paket verwalten installieren sollten.

Ich hoffe, es macht Sachen klarer.

Prost.

+0

Hey, das ist keine gute Idee, weil es nicht zu anderen Installationen Ihres Projektcodes portierbar ist. Wenn ich das Projekt auschecke und versuche, die Tests auszuführen, sollten die Tests mich nicht dazu zwingen, npm -g zu installieren. –