简体   繁体   中英

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. However working with yarn start or npm start does allow running the ng serve command as usual.

Tried installing the latest CLI version for Angular, however nothing helped. 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.

I tried following..

Uninstall the Angular with

npm uninstall -g angular-cli

However there were ng packages still sitting under the %AppData%/npm.

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.

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).

After deleting files, Re-installed everything again. Since,I deleted everything, I had to re-install

NPM

Angular-CLI

NestJs (optional for those who do not want to)

I was able to run the ng serve command at this point .

later I installed few other packages like nodemon etc, however those are just like icing on the cake. 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. please check, just in case, you have the same issue.

Is ng serve command not working after updating to the latest Angular CLI?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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