如何修复npm更新错误?(# npm install npm@latest -g)



如何修复npm更新错误?我以根身份运行

# npm install npm@latest -g

usr/lib
└── (empty)
npm ERR! Linux 4.10.14-200.fc25.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "npm@latest" "-g"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules/npm/node_modules/node-gyp
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall mkdir
npm ERR! EEXIST: file already exists, mkdir '/usr/lib/node_modules/npm/node_modules/node-gyp'
npm ERR! File exists: /usr/lib/node_modules/npm/node_modules/node-gyp
npm ERR! Move it away, and try again.
npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log
npm ERR! code 1

并最终没有 npm。

日志文件位于 https://www.dropbox.com/s/2maxolbxjlnnp7c/npm-debug_error.log.txt?dl=0

我的节点版本是6.10.2,使用Fedora Core 25 64位。npm 版本是 3.10.10

我还在 https://github.com/npm/registry/issues/168 上创建了一个问题

现在,未安装 npm:

新人掌

-bash:/usr/bin/npm: 没有这样的文件或目录

我明天正在关注 https://github.com/brock/node-reinstall,如果没有找到其他建议,请尝试全节点卸载并重新安装。

我运行这个 npm 更新,因为它是在聚合物 2.0 中安装 polymer-cli

的第一步

https://www.polymer-project.org/2.0/docs/tools/polymer-cli

首先,我不建议以 root 用户身份运行 npm 命令,请在此处查看此问题和答案以获取建议 以 root 身份运行 npm 可能会在将来给您带来问题。

您可以使用 npm 更新 npm,如下所示:

npm i -g npm-upgrade

如果您有权限错误,请在此处查看如何修复它们

现在对于您的特定错误,似乎您必须删除该文件夹:

/usr/lib/node_modules/npm/node_modules/node-gyp

我建议删除您的节点并重新安装。

我解决了问题,以 root 身份运行

# dnf remove nodejs
# dnf install nodejs

尝试使用 sudo

sudo npm i -g npm@latest

最新更新