How to start verdaccio by pm2?

2.3k Views Asked by At

pm2 start verdaccio failed, the status is stopped.

$ npm i -g pm2 verdaccio

$ pm2 start verdaccio

enter image description here

3

There are 3 best solutions below

0
On

The problem is pm2 finding verdaccio in the first place. That's why using which solves it, but that is not always possible in Windows.

I've managed to run verdaccio in pm2 on Windows, without even installing it globally (so that I could commit my configs, plugin packages, etc), with this:

// ecosystem.config.js
module.exports = {
  apps : [{
    name: 'verdaccio',
    script: './node_modules/verdaccio/build/lib/cli', // local package, that pm2 can run with "node <script>"
    args : '--config ./config.yaml', // local confis
    node_args: '-r esm', // verdaccio's package didn't contain "type": "module"
    exec_mode: 'fork' // verdaccio does not currently support PM2's cluster mode
  }]
}

PS.: these are my dependencies:

// package.json
  "dependencies": {
    "esm": "^3.2.25",
    "verdaccio": "^5.10.2",
    "verdaccio-activedirectory": "^1.0.2",
    "verdaccio-simplegroup": "^1.0.2"
  },
1
On

I've have been running verdaccio in pm2 for 1 year by know and I use this after installing it globally via npm.

Start

pm2 start `which verdaccio`

Restart

pm2 restart verdaccio

And that works pretty well for me.

0
On

for someone still stumbling upon this problem. you can try deleting the process then starting it again. I solved it this way.