最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node.js: Cannot find module error - Stack Overflow

programmeradmin2浏览0评论

I'm installing a module from the NPM registry with this mand:

npm install dc

All files are installed successfully, but dc fails to resolve a dependency.

$ node web-test.js

module.js:340
    throw err;
    ^
Error: Cannot find module 'sinon'
    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/nikunj/nik_verve/source/node-v0.10.20/node_modules/dc/test/env.js:25:9)
    at Module._pile (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)

I'm installing a module from the NPM registry with this mand:

npm install dc

All files are installed successfully, but dc fails to resolve a dependency.

$ node web-test.js

module.js:340
    throw err;
    ^
Error: Cannot find module 'sinon'
    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/nikunj/nik_verve/source/node-v0.10.20/node_modules/dc/test/env.js:25:9)
    at Module._pile (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)
Share Improve this question edited Dec 12, 2013 at 5:03 hexacyanide 91.9k31 gold badges166 silver badges162 bronze badges asked Oct 17, 2013 at 13:16 Nikunj K.Nikunj K. 9,2094 gold badges45 silver badges54 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

To require the module sinon, you must npm install sinon, not some other module.

Edit: Since you changed your question to installing dependencies, sinon is a devDependency for the package dc, so in order to install it, you must navigate to the module's folder and run npm install. An install off of the global registry will not install developer dependencies for you, but a local run of install will install both normal and development dependencies.

dc.js has dependency on

jsdom, sinon, jquery, vows.

For that install all those dependency

npm install jsdom
npm install sinin
npm install jquery
npm install vows
发布评论

评论列表(0)

  1. 暂无评论