node.js - 命令“ng serve”在命令提示符下工作,但对同一项目的代码不起作用
问题描述
我不熟悉使用 Angular 或 Visual Studio 代码。我安装了运行良好的 node.js 和 npm。运行项目ng serve
的命令,在命令提示符下完美运行。但是,当我切换到 vs 代码的终端区域并运行相同的命令ng serve
时,它会引发如下错误。
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 serve
+ ~~
+ CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
再说一次,如果我使用npm run ng serve
,它的工作方式就像它在 vs code 终端中的工作方式一样。它是如何工作的?如果没有,我应该怎么做才能使它仅用于ng serve
运行项目?
解决方案
我认为您可以Shift + 右键单击您的文件夹,这样您就可以打开 powershell,然后执行npm install -g @angular/cli
然后生成您的项目。我认为它应该工作。
推荐阅读
- c# - 当 UseShellExecute 为真时,C# 以编程方式打开 cmd.exe 并将命令写入控制台
- java - 设置列表视图
- css - css变量calc var min,基于视口宽高的嵌套计算
- java - 用于切换服务器的反应式 Webflux - 是否有益?
- c# - IdentityModel - RequestClientCredentialsTokenAsync
- windows-10 - ROS 与 Windows 10,如何找到正确的命令
- database - 如何 $match 列表中的项目
- javascript - 保持 Azure AD B2C 登录弹出窗口可见
- java - Clob 到字符串的转换
- reactjs - 直接从带有 CORS 异常的应用程序错误中调用 kubernetes api