【问题标题】:Got error while installing npm install -g @angular/Cli安装 npm install -g @angular/Cli 时出错
【发布时间】:2020-12-19 08:02:25
【问题描述】:

D:\CDAC Project\Nodejs>npm install -g @angular/cli

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
C:\Users\Akash Tawade\AppData\Roaming\npm\ng -> C:\Users\Akash Tawade\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

> @angular/cli@10.0.8 postinstall C:\Users\Akash Tawade\AppData\Roaming\npm\node_modules\@angular\cli
> node ./bin/postinstall/script.js

'node' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @angular/cli@10.0.8 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @angular/cli@10.0.8 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!     C:\Users\Akash Tawade\AppData\Roaming\npm-cache\_logs\2020-08-31T07_54_44_998Z-debug.log

我已经阅读了很多文章来解决这个错误以及你管视频,但它不起作用。

【问题讨论】:

标签: node.js angular-cli node-modules npm-install angular-cli-v6


【解决方案1】:

这是我找到的解决方案

解决方案:-

第 1 步:如果 angular/cli 已经安装,则卸载它

npm uninstall -g @angular/cli

第 2 步:尝试删除以下文件夹(如果仍然存在)

C:\Users\Akash Tawade\AppData\Roaming\npm\node_modules\@angular

第 3 步:尝试删除文件“ng”和“ng.cmd”(如果存在)。您将在以下文件夹中找到这些文件。

C:\Users\Akash Tawade\AppData\Roaming\npm\ng 

C:\Users\Akash Tawade\AppData\Roaming\npm\ng.cmd

第 4 步:再次全局安装 angular/cli

npm install -g @angular/cli

【讨论】:

    【解决方案2】:

    只需将以下标签添加到您的命令中:

    npm install -g @angular/cli --unsafe-perm=true --allow-root
    

    【讨论】:

    • 这在通过 NVM 安装 Node 时对我有用。