Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use the CLI / command prompt after ng serve

I realized that every time I run the ng serve then I can't use anymore the command prompt. It's mean - it's not allows new commands. What's the reason and how can I fix it? It's mean, let's say I want to create new service / component from the CLI instead of write it, it's not allows new commands It writes: webpack: Compiled successfully. and then you can't really type new commands

Thanks

like image 381
Menahem Gil Avatar asked Jan 07 '18 06:01

Menahem Gil


2 Answers

When you use ng serve you create a local development server on that shell instance which listens for requests. As long as that server is running, you can’t use that shell instance because it’s busy listening for HTTP requests.

The solution is to a open a new terminal tab or window and run terminal commands from the shell instance from there.

like image 63
pfcodes Avatar answered Oct 18 '22 22:10

pfcodes


If you are working in window, you can use ctrl + C.

Upon which it will ask

Terminate Batch Job (Y/n)?

Just select n and you will be able to edit in the same command prompt.

Please note that after you are done with changes, in order to reflect it on the browser, you need to enter ng serve again.

Also Having said that above, if you want to get access to the command prompt/Console in visual studio(If by chance you are using it). you can get it to further write your code in console provided by the editor. Just press ctrl + ` Combination, you will get the same command prompt.

like image 43
Divya J Avatar answered Oct 18 '22 21:10

Divya J