NodeJS 安装npm install -g @angular/Cli时出错

evrscar2  于 2022-12-22  发布在  Node.js
关注(0)|答案(4)|浏览(273)

D:\CDAC项目\节点js〉npm安装-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

我已经通过了许多文章来解决这个错误,以及你管视频,但它不工作.

zphenhs4

zphenhs41#

只需将以下标记添加到命令中:

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

eyh26e7m2#

这是我找到的解决方案
解决方案:-
步骤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
bttbmeg0

bttbmeg03#

我在运行相同的命令时得到了相同的错误:npm i -g @angular/cli.
node.js是我公司安装的。
PowerShell可以识别nodenpm命令,但CMD不能。
因此,我可以从PS运行npm命令,但有时它会尝试执行这样的命令:

...\cmd.exe /c node ./bin/postinstall/script.js

然后我得到了错误:

'node' is not recognized as an internal or external command, operable program or batch file.

我的问题是环境变量PATH中的一个单引号",它打断了引号后面一半的PATH路径。
即使必须使用注册表编辑器,我也会修复该变量,但这次是我公司的笔记本电脑,没有管理员访问权限,因此唯一的快速修复方法是使用https://cmder.net
命令似乎更正了环境变量PATH。
它删除了引号,并理解nodenpm命令。
而且,是的,我刚刚使用Cmder安装了Angular CLI。

toiithl6

toiithl64#

我只是在卸载和重新安装的答案上加了一点。他们说要删除一些东西的文件夹,是一个隐藏文件夹

相关问题