How to run Angular project on server
Angular is the most used frontend programming language in website development. We can Develop modern, complex, responsive, and scalable web applications with Angular
With this article, I will guide you on how we can make run our angular project on a live server I have used Digital Ocean and Google cloud server to live our project
I have used Ubuntu 20
You must have a node with npm installed on a server if not you can install by following the command
apt update
sudo apt install nodejs npm
You can check the node version by running the following command
node -v
install the Angular CLI globally with:
npm install -g @angular/cli
Go to the project root folder
To download and install npm packages, use the following npm CLI command:
npm install
Use the following CLI command to run your application locally:
ng serve
by default angular take port 4200 and you can see your project running with http://youipaddress:4200/ If the default port 4200 is not available, you can specify another port with the port flag as in the following
ng serve --port 4200
If you are not able to see your project with your IP address run the following
ng serve --host 0.0.0.0
Now if you want to run your project with PM2 to keep the application in the background follow the following step
npm install -g pm2
pm2 start "ng serve"
pm2 start "ng serve --host 0.0.0.0"
pm2 start "ng serve --host 0.0.0.0 --port 4200"
pm2 start "ng serve --host 0.0.0.0 --port 4200" --name "MyApp"
pm2 status
Hope this will help you to make you angular application live on server
Leave a Reply