Exactly.
Take a look at this example:
You can also use ecosystem config.
Create a file ecosystem.config.js in your project’s root folder:
module.exports = {
apps: [
{
name: 'your-app-name',
script: 'npm',
args: 'start',
env: {
NODE_ENV: 'production',
},
exp_backoff_restart_delay: 100,
},
],
};
Now you can start your app in production with:
pm2 start ecosystem.config.js
The code that I’ve defined in the config is equal to: NODE_env=production npm run start