Tag Archives: pm2

Error in node when PM2 starts multiple processes in docker

2021-09-13T15:41:15: PM2 log: App [kafka:1] starting in -cluster mode- 2021-09-13T15:41:15: PM2 log: App name:kafka id:2 disconnected 2021-09-13T15:41:15: PM2 log: App [kafka:2] exited with code [0] via signal [SIGINT] 2021-09-13T15:41:15: PM2 log: App [kafka:2] starting in -cluster mode- 2021-09-13T15:41:15: PM2 log: App [kafka:1] online 2021-09-13T15:41:15: PM2 log: App [kafka:2] online /bin/bash:1 ELF ^ SyntaxError: Invalid or unexpected token

Docker start use CMD["pm2-runtime","process.json"].

The configuration file looks like this

{
    "apps" : [
        {
            "name": "kafka",
            "script": "node main.js --NODE_ENV=test",
            "log_date_format"  : "YYYY-MM-DD HH:mm:ss",
            "log_file"   : "/home/logs/log.log",
            "error_file" : "/home/logs/err.log",
            "out_file"   : "/home/logs/out.log",
            "instances": 3,
            "exec_mode": "cluster"
        }
    ]
  }

Start three Kafka instances in docker. But it keeps reporting errors. The reason is “exec_mode” in the configuration file. Delete it. In docker, remember to use process blocking to run in the foreground mode. Do not use the background, otherwise it will start frequently and cause error.

Error: ENOENT: no such file or directory, uv_cwd Error: Cannot find module

Error: ENOENT: no such file or directory, uv_cwd Error: Cannot find module

new project was deployed to huawei cloud, which is a service provided by express. When it was started with pm2, an error was reported:



initially thought it was express installation error:

Error: Cannot find module 'express'

So multiple installations, various attempts, but it doesn’t work, or even reinstall Node.
later I found that it was fine to start directly with node, so it was fine when I started only one process with pm2. It’s so strange that I started ten projects and didn’t find this kind of problem.
And then I set my sights on

Error: ENOENT: no such file or directory, uv_cwd

The answer, at last, is simply to restart THE PM2

pm2 kill


and then start again:

and then it’s ok to leave work.