簡體   English   中英

安裝 npm install -g @angular/Cli 時出錯

[英]Got error while installing npm install -g @angular/Cli

D:\CDAC 項目\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

我已經閱讀了很多文章來解決這個錯誤以及你管視頻,但它不起作用。

只需將以下標簽添加到您的命令中:

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

這是我找到的解決方案

解決方案:-

第 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

運行相同的命令時出現相同的錯誤: 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

cmder 好像是修正了環境變量PATH。

它刪除了引號並且理解nodenpm命令。

而且,是的,我剛剛使用 Cmder 安裝了 Angular cli。

我只是在卸載和重新安裝的答案中添加了一點。 他們說刪除一些東西的文件夾,是一個隱藏文件夾

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM