angular - ng :术语“ng”未被识别为 cmdlet 的名称,函数 Visual Studio 代码终端
问题描述
在 VS Code 中,当我运行命令时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:npm install -g @angular/cli@latest
从 VS Code 终端执行后低于 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
解决方案
您需要安装最新的 Angular cli 才能使 ng 命令正常工作,您可以从命令终端或 Visual Studio 代码终端运行它
npm install -g @angular/cli@latest
如果仍然无法正常工作,请node.js
从program and feature
.
推荐阅读
- inno-setup - 当 AppId 包含大括号时,检查安装是否全新或升级不起作用
- ffmpeg - FFMPEG 'Fontconfig 错误:无法加载默认配置文件' 错误 Windows
- java - 如何从另一个按钮 onclick 中删除动态创建的图像视图?
- list - 返回没有最后一个元素的列表
- php - 从 DB 获取日期并传递以查看 Laravel
- asp.net-core - 在 VSCode OmniSharp 扩展中找不到指定的 SDK 'Microsoft.NET.Sdk.Web'
- c - AVR uint8_t 没有得到正确的值
- angular - Angular/Karma/Jasmine 单元测试在抛出错误时静默失败
- javascript - 使用 dns.lookup() node.js 按域获取 IP 地址
- typescript - 在 TypeScript 3 中扩展 Document 对象