0

I'm aware a few similar questions have been asked before - mainly here. However, whatever I try to do I cannot get this to work. Screenshot of the issue below. This happens when I attempt to run pm2 start api.

enter image description here

My ecosystem.config.js is:

const nodeServer = (role, debugPort) => ({
    name: role,
    script: 'server/server.js',
    watch: role == 'api' ? ['client', 'server'] : ['server'],
    ignore_watch: ['node_modules'],
    max_memory_restart: '4G',
    node_args: `--inspect=${debugPort}`,
    env: {
      NODE_OPTIONS: '--max-old-space-size=4096',
      NODE_ENV: 'development',
      SERVER_ROLE: role,
    },
    env_production: {
      NODE_ENV: 'production'
    }
})

module.exports = {
    apps: [
      nodeServer('api', 9229),
      nodeServer('task', 9228),
      nodeServer('scheduler', 9227),
    ]
}

PM2 is installed globally on my system running 5.1.0 (which I believe is the current latest). Node version is 14.13.0. I get the same error if I try on node versions 10 & 12. I'm really struggling to figure this one out.

wmash
  • 4,032
  • 3
  • 31
  • 69
  • You should execute the command: `pm2 start ecosystem.config.js` instead of `pm2 start api`. Once the pm2 apps are up and running, then the command `pm2 (start | stop | restart) api ` would be applicable. – Dhruv Shah Jun 21 '21 at 13:53
  • 1
    I am using `pm2` version `3.5.0` and `node` version `v14.16.0` and your `ecosystem.config.js` file works correctly for me when I execute the command `pm2 start ecosystem.config.js` – Dhruv Shah Jun 21 '21 at 14:01
  • @DhruvShah that is working, thank you!! Clearly it is something to do with later versions of PM2 – wmash Jun 21 '21 at 14:58

0 Answers0