NPM没有安装依赖项?


8

无法让NPM npm install -d在具有定义package.json文件的项目目录中安装依赖项。

这是我的package.jsonhttps : //gist.github.com/3068312

在清除项目根目录的节点模块文件夹(rm -rf node_modules)后,我npm install -d在项目根目录中运行并受到欢迎:

(ssh) /vagrant git:master ❯ npm install -d                                                                                                                                                                  
npm info it worked if it ends with ok
npm info using npm@1.1.4
npm info using node@v0.6.12
npm info preinstall redeye@0.0.1
npm http GET https://registry.npmjs.org/sinon
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/mocha
npm http GET https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/sinon
npm http 304 https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/mocha
npm http 304 https://registry.npmjs.org/request
npm info into /vagrant underscore@1.3.3
npm info into /vagrant mocha@1.3.0
npm info into /vagrant sinon@1.3.4
npm info into /vagrant request@2.9.203
npm info installOne underscore@1.3.3
npm info installOne mocha@1.3.0
npm info installOne sinon@1.3.4
npm info installOne request@2.9.203
npm info unbuild /vagrant/node_modules/underscore
npm info unbuild /vagrant/node_modules/mocha
npm info unbuild /vagrant/node_modules/sinon
npm info unbuild /vagrant/node_modules/request
npm ERR! error installing underscore@1.3.3
npm info unbuild /vagrant/node_modules/underscore
npm ERR! error rolling back underscore@1.3.3 Error: UNKNOWN, unknown error '/vagrant/node_modules/underscore'

npm ERR! Error: ENOENT, no such file or directory '/vagrant/node_modules/underscore/package.json'
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /vagrant/npm-debug.log npm
npm ERR! 
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-d"
npm ERR! cwd /vagrant
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! path /vagrant/node_modules/underscore/package.json
npm ERR! code ENOENT
npm ERR! message ENOENT, no such file or directory '/vagrant/node_modules/underscore/package.json'
npm ERR! errno {}
npm ERR! error installing request@2.9.203
npm info unbuild /vagrant/node_modules/request
npm ERR! error rolling back request@2.9.203 Error: UNKNOWN, unknown error '/vagrant/node_modules/request'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /vagrant/npm-debug.log
npm not ok

如果我重新运行npm install -d,该错误将更改为下一个软件包的内容……如果我一遍又一遍地运行它,则最终不再抱怨并输出:

(ssh) /vagrant git:master ❯ npm install -d                                                                                                                                                               
npm info it worked if it ends with ok
npm info using npm@1.1.4
npm info using node@v0.6.12
npm info preinstall redeye@0.0.1
npm info build /vagrant
npm info linkStuff redeye@0.0.1
npm info install redeye@0.0.1
npm info postinstall redeye@0.0.1
npm info ok

但是,没有安装任何这些软件包的依赖项。例如,cheerio它具有一些依赖性,因此当我尝试运行测试套件时,会遇到以下问题:

(ssh) /vagrant git:master ❯ mocha --compilers coffee:coffee-script --watch spec/*                                                                                                                           


node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'cheerio-select'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)

是什么赋予了?我在一个Vagrant虚拟盒子中的Ubuntu Precise64上。

Answers:



0

你试过了npm cache clean吗?

前几天,我在尝试为Qunit安装依赖项时遇到了麻烦,这是由于phantonjs在第一次运行时无法构建,但是当我重新安装时,npm并没有重新提取二进制文件,而只是试图从缓存的内容中构建。清空缓存并重新运行后,将npm install其重新提取并成功构建。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.