@angular/cli@8.3.19 postinstall 脚本失败

Ant*_*IER 6 node.js npm angular

嗨,我无法使用npm install -g @angular/cli@8.3.19. 我不断得到这个:

> node ./bin/postinstall/script.js

module.js:549
    throw err;
    ^

Error: Cannot find module '/root/.nvm/versions/node/v13.0.1/lib/node_modules/@angular/cli/bin/postinstall/script.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @angular/cli@8.3.19 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @angular/cli@8.3.19 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-26T00_10_33_515Z-debug.log
Run Code Online (Sandbox Code Playgroud)

节点版本:13.0.1 Npm
版本:6.13.1
Ubuntu 版本:18.04.2

我也尝试过不指定 CLI 版本。

Ant*_*IER 14

我尝试使用我在网上找到的这个命令:

npm install -g @angular/cli@8.3 --unsafe-perm=true --allow-root
Run Code Online (Sandbox Code Playgroud)

它奏效了。


小智 3

尝试与 一起运行sudo npm。在Ubuntu上,您需要以root权限运行。这取决于你如何安装节点。

sudo npm install -g @angular/cli@8.3.19
Run Code Online (Sandbox Code Playgroud)

另一方面,尝试安装node 12和LTS版本以获得更安全的版本。

希望能帮助到你