0

I am trying to run a node api as a service but when I run the following command

C:\Windows\System32>pm2-service-install -n 0PM2 

it asks the following question

Perform environment setup (recommended)?

I put yes but it stays there and does nothing

What could be the problem?

senseilex
  • 17
  • 1
  • 5

1 Answers1

1

You can simply install the pm2 package.

npm install pm2 -g

Run the module that has your server

 pm2 start app.js

If the above things are working fine, it shows your installation and configuration are correct. Now, use pm2 commands:

pm2 startup

follow the command from the o/p of above command

pm2 save

It seems you are using windows, you should use these steps:

  1. download the pm2-installer from here.
  2. Copy the entire pm2-installer directory onto the target machine, then run:
npm run setup
  1. On Windows, the setup script assumes you have already configured npm to use prefix and cache directories in a location accessible to the Local Service user. If not, it will issue a warning and ask if you're sure you'd like to proceed. To set up npm automatically, run configure first:
npm run configure
npm run setup

Check here for more details.

Apoorva Chikara
  • 8,277
  • 3
  • 20
  • 35