运行命令后npm install -g @angular \ cli我收到一个npm ERR! 代码ENOLOCAL

我最初使用运行Windows 10的计算机,也运行Windows 8.1的另一台计算机,但我仍然在两台计算机上收到相同的消息。 错误日志是:

npm ERR! code ENOLOCAL npm ERR! Could not install from "@angular\cli" as it does not contain a package.json file. 

节点和npm版本分别为8.2.1和5.3.0。

当我在git bash上运行命令时,我收到了一个不同的错误信息。 错误日志是:

 npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name "@angularcli": Tags may not have any characters that encodeURIComponent encodes. 

你的命令是错误的:

这是@angular/cli正斜杠而不是@angular\cli

 npm install -g @angular/cli 

为了在windows上安装angular-cli使用

npm install -g @angular/cli代替npm install –g @angular-cli