Logo

dev-resources.site

for different kinds of informations.

Deploy Nest JS App using PM2 on Linux (Ubuntu) Server

Published at
6/11/2022
Categories
nestjs
devops
pm2
ubuntu
Author
deadwin19
Categories
4 categories in total
nestjs
open
devops
open
pm2
open
ubuntu
open
Author
9 person written this
deadwin19
open
Deploy Nest JS App using PM2 on Linux (Ubuntu) Server

In this article, I will cover steps that will help you to deploy Nest JS application on Linux Server. I am using Ubuntu 20.04 LTS **during writing this article and I am assuming you have already installed **Node.js on your server.

Step 1 (Install Nest JS CLI)

Generally, we use npm i command to run all the dependencies but that will not install Nest JS so we have to manually install Nest JS CLI

$ sudo npm i -g @nestjs/cli

Step 2 (Install PM2)

If you didnโ€™t install PM2 earlier then you have to use following command to install PM2.

$ sudo npm install pm2@latest -g

If you want to get more details about PM2 commands, then please visit url: PM2 Commands

Step 3 (Clone Code Repository)

You can clone your repo using following command and install necessary dependencies. If you want more details on Cloning, please refer article: Clone Specific Git Branch

$ git clone http://coderepo.com/projectname.git
$ cd projectname
$ npm install

Step 4 (Build Project)

For Nest JS app, you have to first generate a build then only you can run the project on server.

$ npm run build

Step 5 (Run Project)

If build is generated successfully then will create /dist folder under root directory. Now you can run your project using following PM2 command

$ pm2 start dist/main.js --name <application_name>

application_name you can use to give unique app name so that you can easily identify your apps in pm2 list.

There are some PM2 commands to make your application auto restart after system reboot also

$ pm2 startup systemd
$ pm2 save

Conclusion

I hope this article will help you deploy your Nest JS application on Linux Server. If you liked the solution, please hit the Clap button or comment if you have any suggestion or feedback.

pm2 Article's
30 articles in total
Favicon
Deploy NestJS and NextJS application in same server using pm2 and Nginx
Favicon
Guia de Comandos PM2
Favicon
๐Ÿš€ Deploying Node.js Application with PM2, NGINX, and SSL Configuration ๐Ÿš€
Favicon
Monitoring PM2 in production
Favicon
Mastering PM2: Optimizing Node.js and Next.js Applications for Performance and Scalability
Favicon
Setting Up PM2 for Multi-User Access on Ubuntu Instance
Favicon
Manual deployment of NestJS and Angular applications on a dedicated server via "Docker Compose" and "PM2"
Favicon
Build applications on NestJS and Angular and run them in two versions: via PM2 and via Docker Compose
Favicon
An example of a simple update of NestJS-mod libraries
Favicon
Using pm2 to Manage Node.js Applications
Favicon
Using Screen and PM2 for Deploying, Debugging, and Running NestJS in Production
Favicon
Host Multiple Node Apps with nginx, pm2 with SSL certificate
Favicon
Node.js PM2 Orchestration Explained
Favicon
Managing Logs with PM2 and pm2-logrotate
Favicon
Streamlining PM2 Startup for Node.js Applications: A Comprehensive Guide
Favicon
Managing Next.js and NestJS Applications in Production with PM2
Favicon
Deploy a Full Stack Web App to VPS Server with NGINX andย PM2!
Favicon
Como utilizar o PM2 para gerenciar aplicaรงรตes
Favicon
Guide to Running a Node Server in Nx Monorepo using PM2 Process Manager
Favicon
How to run old nodejs Project into new nodejs project
Favicon
CentOS 7 NodeJS Kurulumu
Favicon
How to start node.js app with pm2
Favicon
How to start node.js app with pm2
Favicon
Deploying Multiple NodeJS Servers on a Single DigitalOcean Droplet; Managed by PM2, Without Using an ecosystem.config.js file
Favicon
Automatic deploys with PM2, Caddy, and GitHub Actions
Favicon
Utilizando PM2 (Basico)
Favicon
Experience on PM2 Tricks to manage your NodeJs processes
Favicon
Deploy Nest JS App using PM2 on Linux (Ubuntu) Server
Favicon
Install PM2 (Process Manager 2)
Favicon
Generate server block (virtual hosts) for nginx dynamically

Featured ones: