Auto Start NodeJS NPM React App after Reboot using PM2

To auto start node.js npm app after reboot, one way is to use pm2.

First instead pm2:
> npm install -g pm2

Configure pm2 to start as root
> pm2 startup -u root

Add the npm app to pm2 (example shown here is a react app, replace “yourapp” with the name of your react app)
> pm2 start node_modules/react-scripts/scripts/start.js –name “yourapp”

Save the configuration
> pm2 save

Now when you reboot the server, your npm app will be automatically run.