Member-only story

How to deploy Node.js app with PM2 in production — boobo94

Bogdan Alexandru Militaru
2 min readOct 13, 2019

To deploy Node.js app with PM2 it’s very simple and nowadays is very important to use the right tool which facilitate your time. Time is the most valuable resource that a human being can own, so try to avoid those tools which are time-consuming.

I would like to present below a simple solution found by me to deploy Node.js app with PM2. I needed a fast solution and with less configuration as possible. I tried as well Forever JS, you can find the NPM page here or Github repository. But I prefer the documentation and explanation of [PM2](https://pm2.keymetrics.io/).

Firstly you need to create a pm2.json file and put it preferably in the root of your project:

{
"apps": [
{
"name": "web",
"exec_mode": "cluster",
"instances": "max",
"script": "./lib/server.ts",
"interpreter": "ts-node",
"env": {
"ENV": "prod",
"PORT": 3000,
"DB_USERNAME": "boobo94_username",
"DB_PASSWORD": "123",
"DB_NAME": "some_db_name",
"DB_HOST": "127.0.0.1",
"DB_DIALECT": "postgres",
"DB_PORT": 5432,
"SECRET_KEY": "boobo94_is_my_secret_key",
}
}
]
}

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response