How to run node js file in background process on window server?

Dara Vichit picture Dara Vichit · Oct 6, 2016 · Viewed 21.2k times · Source

I was create a node.js project and upload it to my window server to provide api service for mobile application. when I open command prompt and type

node app.js

It run correctly, but when I close the command prompt my node.js server was stop running. How to make it still running when I close commend prompt?

example on Ubuntu I use command

nohup 

How to do like this on window

Answer

Himani Agrawal picture Himani Agrawal · Oct 6, 2016

You can make the process run in background using pm2

pm2 start app.js --watch

This will start the process and will also look for changes in the file. More about watch flag