Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.27k stars 2.61k forks source link

LRU is not a constructor #5749

Open p1k2i opened 7 months ago

p1k2i commented 7 months ago

What's going wrong?

Cannot start nodejs application with command pm2 start dist/app.js --node-args="-r tsconfig-paths/register"

How could we reproduce this issue?

I can create new repository with a simple project demostrating the problem if needed.

Supporting information

I can start the same application successfully from console if I put the command node -r tsconfig-paths/register dist/app.js, so it looks like a problem with pm2. I tried different versions o node, npm and pm2 - is the same. It was working before on a production server, but not anymore and I don't understand what happens.

TypeError: LRU is not a constructor
at Object.<anonymous> (/home/p1k/.nvm/versions/node/v20.11.0/lib/node_modules/pm2/node_modules/semver/classes/range.js:202:15)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/home/p1k/.nvm/versions/node/v20.11.0/lib/node_modules/pm2/node_modules/semver/classes/comparator.js:141:15)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)

ChatGPT-4 answer: "The error message you're seeing indicates that there's a problem with the LRU (Least Recently Used) cache in the semver module that pm2 is using. It's possible that there's a version mismatch issue between the semver and lru-cache packages."

p1k2i commented 7 months ago

My package-lock.json of the project also includes lru-cache and semver. I am not sure, maybe it can affect?

"node_modules/lru-cache": {
      "version": "6.0.0",
      "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
      "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
      "dependencies": {
        "yallist": "^4.0.0"
      },
      "engines": {
        "node": ">=10"
      }
    },
"node_modules/semver": {
      "version": "5.7.2",
      "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
      "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
      "dev": true,
      "bin": {
        "semver": "bin/semver"
      }
    },