NPM完全损坏,升级失败后将不会重新安装

时间:2020-10-04 19:40:33

标签: npm npm-install

Mac Catalina 10.15.6

我已经安装了npm。我想升级,所以我运行了以下程序。

   npm install -g npm

下面是输出:

$ name @ $ names-MacBook-Pro台式机%npm install -g npm / usr / local / bin / npx-> /usr/local/lib/node_modules/npm/bin/npx-cli.js / usr / local / bin / npm-> /usr/local/lib/node_modules/npm/bin/npm-cli.js npm ERR!代码EEXIST npm ERR! syscall symlink npm错误!路径 ../../../lib/node_modules/npm/man/man1/npm-bin.1 npm ERR!目的 /usr/local/share/man/man1/npm-bin.1 npm错误! errno -17 npm错误! EEXIST:文件已存在,符号链接 '../../../lib/node_modules/npm/man/man1/npm-bin.1'-> '/usr/local/share/man/man1/npm-bin.1'npm ERR!文件已存在: /usr/local/share/man/man1/npm-bin.1 npm错误!删除现有文件 然后重试,或者运行npm npm ERR!用--force覆盖文件 鲁ck。

npm ERR!此运行的完整日志可以在以下位置找到:npm ERR!
/Users/$name/.npm/_logs/2020-10-04T14_41_02_611Z-debug.log

现在所有NPM命令都会失败。

zsh: command not found: npm

所有来自:

npm -v

sudo npm install npm -g

2 个答案:

答案 0 :(得分:1)

我只是用家用啤酒来升级NPM,它删除并重新安装了所有必需的文件。

答案 1 :(得分:0)

这通常在Mac上适用于我:

brew upgrade
brew cleanup
brew install npm

(请注意,如果您没有xcode工具,请使用xcode工具-尝试xcode-select --install或签出answer。)

现在,再次尝试npm install,看看是否有任何改变。

另外,请参见此potentially related answer