Angular(2) - Running two projects with CLI
Asked Answered
M

3

15

I was wondering if it is possible to work on two Angular(2) projects at the same time. I open my first project using ng serve and it runs on the server and when I save it it updates. But of coarse when I try to open another project with ng serve it will tell you that "port:4200 is already in use". Is there a way to open a project on a different port?

Seeing that this is a virtual server, I can not think that just giving it another port number can be to difficult. I do not want to log out of the one project the whole time, and then into the second one and back again after changing just one line to see if it works.

Regards

Mercantile answered 9/2, 2017 at 15:51 Comment(0)
L
37

Open 2nd project then run this command:

ng serve --port 4210

Change port as you want, then open browser: localhost:[port]

Following this section:

https://github.com/angular/angular-cli#generating-and-serving-an-angular-project-via-a-development-server

Lau answered 9/2, 2017 at 15:54 Comment(4)
Hi Tiep, do I run this for the second project after running ng serve normally for the first project? And then just open localhost:4210 in browser for second project? Are the port numbers specific or can I use any numbers, just for clarity?Mercantile
Ah ok, got the answers from the links... Thanks allot!!Mercantile
use any unuse port: > 1024, because almost port from 1 -1024 are use by some service: 80 -> http. 443 -> https, 21 -> ssh, ... angular cli by default using port 4200Lau
That works fine. Thanks. Better find open ports first and assign it.Enlace
O
6

If you're using angular-cli, It is pretty easy :

In console run :

ng serve --host 0.0.0.0 --port 4201 --live-reload-port 4915

For reference : https://github.com/angular/angular-cli

Overstay answered 9/2, 2017 at 15:54 Comment(0)
W
1

Open Seconde terminal in vsCode

ng serve --port 4210

Change port number as you want, then open browser: localhost:[port]

Wolfenbarger answered 27/8, 2020 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.