npm 因 "ERR! cb() never called" 崩溃

npm crashes with "ERR! cb() never called"

我正在尝试使用

安装 vue-cli

npm install -g @vue/cli

我收到以下错误

Unhandled rejection Error: EACCES: permission denied, mkdir '/home/moeketsi/.npm/_cacache/tmp'

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>

npm ERR! A complete log of this run can be found in:
npm ERR!  /home/moeketsi/.npm/_logs/2019-08-02T07_16_39_683Z-debug.log

日志文件是available here

当我尝试 运行 使用 sudo 命令时,我得到

sudo: npm: command not found

我使用的是节点 v10.16.1,npm 版本是 6.9.0。我从他们的 website. I tried the following suggestions from this and from maybe a slightly different case、none 的建议中安装了 node.js。

这是权限问题。转到根目录并尝试安装。

从 root 用户尝试:

sudo -i

npm install -g @vue/cli

如果你想维护当前目录。

sudo -s

npm install -g @vue/cli

根据 documentation,如果您安装了以前的版本,您可能会遇到问题。您可以检查使用 npm list -g.

安装的所有软件包

要卸载以前版本的 vue-cli 使用 npm uninstall vue-cli -g

如果不是这种情况,您可以尝试 运行 npm cache clear --force 并尝试重新安装。