我是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代码终端中应该如何工作一样。它是这样工作的吗?如果没有,我应该怎么做才能让它只使用ng serve
来运行项目?
我认为您可以Shift+右键单击文件夹中的,这样您就可以打开powershell,然后执行npm install -g @angular/cli
,然后生成您的项目。我认为它应该起作用。