LRU is not a constructor
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
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."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing pm2 start dist/app.js --node-args="-r tsconfig-paths/register" with Node.js 20, comparing it with the working node -r tsconfig-paths/register dist/app.js command. Read the stack-trace locations in semver/classes/range.js and semver/classes/comparator.js and inspect the PM2 dependency setup. Done means the reported PM2 command starts successfully or the issue is narrowed to a reproducible dependency compatibility problem.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100