在VS代码中,当我运行命令ng build
时,会出现错误
PS D:\Dashboard\Test1> ng build
ng : The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ng build
+ ~~
+ CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我在Path
中添加了这些环境变量
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;
C:\Users\Avind\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Users\Avind\AppData\Roaming\npm;
我怎样才能摆脱这个问题?
注意:我有node.js
在C:\Program Files\nodejs
。从命令提示符ng new project
不工作,而是使用node.js
命令。
编辑1:从VS代码终端执行npm install -g @angular/cli@latest
后,出现在msg和ng
cmd以下的不工作状态
PS D:\Path\Test1> npm install -g @angular/cli@latest
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\Avind\AppData\Roaming\npm\ng -> C:\Users\Avind\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
> @angular/cli@9.1.9 postinstall C:\Users\AR20095474\AppData\Roaming\npm\node_modules\@angular\cli
> node ./bin/postinstall/script.js
+ @angular/cli@9.1.9
updated 1 package in 53.477s
发布于 2022-03-08 12:25:40
我通过运行以下三个命令解决了这个问题:-
npm uninstall -g @angular/cli angular-cli
npm cache clean or npm cache clean --force
npm install -g @angular/cli@latest
成功了。
https://stackoverflow.com/questions/62527278
复制相似问题