简体   繁体   English

更新到最新的 Angular CLI 后,ng serve 命令不起作用

[英]ng serve command not working after updating to the latest Angular CLI

After updating to the latest version of Angular CLI, I am not able to execute the ng serve command any more.更新到最新版本的 Angular CLI 后,我无法再执行ng serve命令。 However working with yarn start or npm start does allow running the ng serve command as usual.然而,使用yarn startnpm start确实允许像往常一样运行ng serve命令。

Tried installing the latest CLI version for Angular, however nothing helped.尝试为 Angular 安装最新的 CLI 版本,但没有任何帮助。 Following is the Command Prompt snapshot for reference.以下是命令提示符快照以供参考。

Microsoft Windows [Version 10.0.17134.885] (c) 2018 Microsoft
 Corporation. All rights reserved.

 D:\Development\Celebro>ng serve 'ng' is not recognized as an internal
 or external command, operable program or batch file.

 D:\Development\Celebro>ng 'ng' is not recognized as an internal or
 external command, operable program or batch file.

 D:\Development\Celebro>yarn start 
> yarn run v1.17.3 

> $ ng serve 

> 15% building 3/3 modules 0 activeTerminate batch job (Y/N)? y

 D:\Development\Celebro>npm start

> Celebro@0.0.0 start D:\Development\Celebro
> ng serve

> 10% building 3/3 modules 0 activeTerminate batch job (Y/N)? y

 D:\Development\Celebro>

I've installed the latest CLI/Node/checked Windows Environment Path variables, nothing helped so far.我已经安装了最新的 CLI/节点/检查过的 Windows 环境路径变量,到目前为止没有任何帮助。

I tried following..我试过跟随..

Uninstall the Angular with卸载 Angular

npm uninstall -g angular-cli npm卸载 -g angular-cli

However there were ng packages still sitting under the %AppData%/npm.然而,%AppData%/npm 下仍然有 ng 包。

Issue still persisted.问题仍然存在。 as Un-installing and Re-installing them again didn't help.因为卸载并重新安装它们没有帮助。
Also noticed that the ng.cmd file was being removed in the process.还注意到ng.cmd文件在此过程中被删除。

So I decided to ruin it further (!), and practically deleted almost everything under the node_modules folder (yarn was the only folder, I didn't touched).所以我决定进一步破坏它(!),并且几乎删除了node_modules文件夹下的几乎所有内容(yarn 是唯一的文件夹,我没有碰过)。

After deleting files, Re-installed everything again.删除文件后,重新安装所有东西。 Since,I deleted everything, I had to re-install因为,我删除了所有内容,我不得不重新安装

NPM新产品管理

Angular-CLI Angular-CLI

NestJs (optional for those who do not want to) NestJs (对于那些不想的人可选)

I was able to run the ng serve command at this point .此时我能够运行 ng serve 命令

later I installed few other packages like nodemon etc, however those are just like icing on the cake.后来我安装了一些其他软件包,如 nodemon 等,但是这些就像锦上添花。 Hope this helps anyone who falls in to this trouble again.希望这可以帮助任何再次陷入困境的人。

I guess the real issue was with ng.cmd file getting corrupt/deleted after uninstall.我想真正的问题是卸载后 ng.cmd 文件损坏/删除。 please check, just in case, you have the same issue.请检查,以防万一,你有同样的问题。

Is ng serve command not working after updating to the latest Angular CLI?更新到最新的 Angular CLI 后,ng serve 命令是否不起作用?

Than you can use this command:比你可以使用这个命令:

ng serve -o

It will run Angular CLI, but you have to wait a little bit Because it is compiling all data in your folder它将运行 Angular CLI,但您必须稍等一下,因为它正在编译您文件夹中的所有数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM