Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular(2) - Running two projects with CLI

Tags:

angular

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

like image 896
Alfa Bravo Avatar asked Feb 09 '17 15:02

Alfa Bravo


People also ask

Can I run two angular projects at a time?

The Angular CLI since version 6 allows us to create a multi-project workspace to manage multiple Angular apps. We do that first by creating an empty workspace. A Workspace is a collection of Angular apps, projects, or libraries. Later we can add multiple projects to the workspace.

How do you share angular components between projects and apps?

To get started, go ahead and install bit-cli, then head over to the project from which to share the components, and initialize a bit workspace. Then, head over to bit. dev and create a free account. Then, create a collection to host your shared components.


3 Answers

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

like image 158
Tiep Phan Avatar answered Oct 03 '22 09:10

Tiep Phan


Open Seconde terminal in vsCode

ng serve --port 4210

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

like image 22
Sushil Avatar answered Oct 03 '22 08:10

Sushil


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

like image 38
Pezetter Avatar answered Oct 03 '22 10:10

Pezetter