npm 安装出错

Posted

技术标签:

【中文标题】npm 安装出错【英文标题】:Error with npm install 【发布时间】:2015-03-21 09:03:35 【问题描述】:

我试图在我的机器上设置节点....安装了 npm 和 grunt-cli 并在根目录下使用 -g 并且当我在我的代码目录中运行 npm install 时出现以下错误

sudo npm install
npm WARN prefer global grunt-cli@0.1.13 should be installed with -g
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/watchify/node_modules/browserify requires resolve@'~0.7.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/resolve,
npm WARN unmet dependency which is version 1.0.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/watchify/node_modules/browserify requires through2@'^1.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/watchify/node_modules/through2,
npm WARN unmet dependency which is version 0.5.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-config requires mout@'~0.9.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-json requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires async@'~0.2.8' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/async,
npm WARN unmet dependency which is version 0.1.22
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires lru-cache@'~2.3.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/lru-cache,
npm WARN unmet dependency which is version 2.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires request@'~2.27.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/request,
npm WARN unmet dependency which is version 2.42.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires mkdirp@'~0.3.5' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/mkdirp,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/decompress-zip requires nopt@'~2.2.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/nopt,
npm WARN unmet dependency which is version 3.0.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/inquirer requires lodash@'~2.4.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/lodash,
npm WARN unmet dependency which is version 0.10.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/insight requires async@'^0.9.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/async,
npm WARN unmet dependency which is version 0.1.22
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/insight requires chalk@'^0.5.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/chalk,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/insight requires inquirer@'^0.6.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/inquirer,
npm WARN unmet dependency which is version 0.7.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-json requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires lru-cache@'~2.3.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/lru-cache,
npm WARN unmet dependency which is version 2.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires request@'~2.27.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/request,
npm WARN unmet dependency which is version 2.42.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires mkdirp@'~0.3.5' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/mkdirp,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/decompress-zip requires nopt@'~2.2.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/nopt,
npm WARN unmet dependency which is version 3.0.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/insight requires chalk@'^0.5.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/chalk,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/insight requires inquirer@'^0.6.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/inquirer,
npm WARN unmet dependency which is version 0.7.1
bhavan@bhavan-Inspiron-N5010:~/oyo/website$ sudo npm install
npm WARN prefer global grunt-cli@0.1.13 should be installed with -g
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/watchify/node_modules/browserify requires resolve@'~0.7.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/resolve,
npm WARN unmet dependency which is version 1.0.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/watchify/node_modules/browserify requires through2@'^1.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-browserify/node_modules/watchify/node_modules/through2,
npm WARN unmet dependency which is version 0.5.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-config requires mout@'~0.9.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-json requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires async@'~0.2.8' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/async,
npm WARN unmet dependency which is version 0.1.22
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires lru-cache@'~2.3.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/lru-cache,
npm WARN unmet dependency which is version 2.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires request@'~2.27.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/request,
npm WARN unmet dependency which is version 2.42.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/bower-registry-client requires mkdirp@'~0.3.5' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/mkdirp,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/decompress-zip requires nopt@'~2.2.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/nopt,
npm WARN unmet dependency which is version 3.0.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/inquirer requires lodash@'~2.4.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/lodash,
npm WARN unmet dependency which is version 0.10.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/insight requires async@'^0.9.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/async,
npm WARN unmet dependency which is version 0.1.22
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/insight requires chalk@'^0.5.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/chalk,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/insight requires inquirer@'^0.6.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bower-task/node_modules/bower/node_modules/inquirer,
npm WARN unmet dependency which is version 0.7.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-json requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.5
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires lru-cache@'~2.3.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/lru-cache,
npm WARN unmet dependency which is version 2.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires request@'~2.27.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/request,
npm WARN unmet dependency which is version 2.42.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/bower-registry-client requires mkdirp@'~0.3.5' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/mkdirp,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/decompress-zip requires nopt@'~2.2.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/nopt,
npm WARN unmet dependency which is version 3.0.1
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/insight requires chalk@'^0.5.1' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/chalk,
npm WARN unmet dependency which is version 0.5.0
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/insight requires inquirer@'^0.6.0' but will load
npm WARN unmet dependency /home/bhavan/oyo/website/node_modules/grunt-bowercopy/node_modules/bower/node_modules/inquirer,
npm WARN unmet dependency which is version 0.7.1
er code here

【问题讨论】:

能否请您发布您的 Node 和 NPM 版本号以及您的 package.json? 你安装了 ''' sudo apt-get install nodejs 吗? Grunt install error/s: "should be installed with -g" 的可能重复项 另外,关于unmet dependencies。 作为一项规则,您不要以 root 身份执行 npm install。不确定这是否会影响您,但我一直以服务帐户用户或登录用户的身份进行操作。 【参考方案1】:

在我的系统上,这是由于安装不正确的软件包造成的(安装中途中止)。

在我的例子中,所有npm WARN unmet dependency /path/node_modules/package/ 消息都指向同一个包,所以我从我的 node_modules 目录中删除了那个包并重新安装了它。这解决了我遇到的所有问题。 (即使尝试安装不依赖于问题包的包,npm 也会出现此错误,这仍然解决了问题)

在你的情况下,列出了几个包,所以:

删除你的节点模块目录

rm -r node-modules

重新安装你的包

npm install

如果您尝试安装的软件包仍未安装,请重新安装。

npm install --save package

对于遇到此问题的其他人,如果您尝试安装的软件包是全局的,您可能需要删除您的全局 node_modules 目录。 npm ls -g --depth 0 将告诉您全局node_modules 目录的位置,并为您提供已安装软件包的列表。请注意这些,因为您需要手动重新安装它们。

【讨论】:

以上是关于npm 安装出错的主要内容,如果未能解决你的问题,请参考以下文章

npm 安装出错

CentOS 安装 pm2 运行出错

使用 npm 安装 angular/cli 时出错

React-navigation- dependencies (安装 NPM 导航依赖包安装时出错)

使用“ npm install wdio”安装webdriverIO时出错,

在 MAC 上安装电话间隙时出错