NPM 没有安装依赖项?

NPM 没有安装依赖项?

npm install -d在我的项目目录中使用定义的文件来安装 NPM 依赖项时遇到问题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 [email protected]
npm info using [email protected]
npm info preinstall [email protected]
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 [email protected]
npm info into /vagrant [email protected]
npm info into /vagrant [email protected]
npm info into /vagrant [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
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 [email protected]
npm info unbuild /vagrant/node_modules/underscore
npm ERR! error rolling back [email protected] 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 [email protected]
npm info unbuild /vagrant/node_modules/request
npm ERR! error rolling back [email protected] 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 [email protected]
npm info using [email protected]
npm info preinstall [email protected]
npm info build /vagrant
npm info linkStuff [email protected]
npm info install [email protected]
npm info postinstall [email protected]
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)

怎么回事?我在 Ubuntu Precise64 上流浪汉虚拟盒子。

答案1

也许与 vagrant 上的符号链接相关的某些错误以及此问题: https://github.com/isaacs/npm/issues/2380

尝试

npm install --no-bin-link

也在这里解释:http://www.conroyp.com/2013/04/13/symlink-shenanigans-nodejs-npm-express-vagrant/

答案2

你有没有尝试过npm cache clean

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

相关内容