npm install 出错

4

我正在尝试在我的电脑上安装Node... 在根目录下使用-g安装了npm和grunt-cli,但当我在代码目录内运行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文件? - Paul
你已经安装了 "sudo apt-get install nodejs" 吗? - kahonmlg
可能是重复的问题:Grunt安装错误:“应该使用-g安装” - Jonast92
另外,关于未满足的依赖项(unmet dependencies),请参考此链接:https://dev59.com/8WIi5IYBdhLWcg3w_AbV。 - Jonast92
2
通常情况下,不建议以root身份运行npm install。虽然我不确定这是否会影响您的情况,但我一直建议使用服务账户用户或已登录的用户来运行该命令。 - Paul
1个回答

4
在我的系统上,这是由于一个未正确安装的软件包导致的(安装在中途被中止)。
在我的情况下,所有 "npm WARN unmet dependency /path/node_modules/package/" 的消息都指向同一个软件包,所以我从我的 node_modules 目录中删除了该软件包并重新安装了它。这解决了我遇到的所有问题。(即使尝试安装不依赖于有问题的软件包的软件包时,npm 仍会报告此错误,并且这仍然解决了问题)
在你的情况下,列出了几个软件包,因此:
  • Remove your Node modules directory

    rm -r node-modules
    
  • Reinstall your packages

    npm install
    
  • If the package that you tried install is still not installed, reinstall it.

    npm install --save package
    
如果你遇到这个问题,如果你想要安装的包是全局的,你可能需要删除你的全局node_modules目录。通过执行npm ls -g --depth 0命令,你可以找到你的全局node_modules目录的位置,并获得已安装包的列表。记下这些内容,因为你需要手动重新安装它们。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接