npm 安装时出错

Error with npm install

本文关键字:出错 安装 npm      更新时间:2023-09-26

>im 试图在我的机器上设置节点....在根目录安装了带有 -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

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

就我而言,所有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目录的位置,并为您提供已安装软件包的列表。请注意这些,因为您需要手动重新安装它们。