fix: cannot find module ansis on Node.js < 14 #5986
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @Unitech,
This PR fixes the incompatibility with Node.js <= 12 introduced with the PR #5983. I'll leave this as a draft for now.
Although PM2 v6 officially requires at least Node.js 16, many users continue to run pm2 v6 on unsupported Node.js versions 10–12.
Many other dependencies require Node.js 14+:
By the way, the README should be updated to say:
How to reproduce the issue
The pm2
6.0.6uses package ansis4.0.0(node >= 14).Check package.json:
Run from pm2 project directory:
Output:
How to fix this incompatibility issue
Replace ansis
4.0.0with special version4.0.0-node10compatible with Node.js 10+:"dependencies": { .. - "ansis": "4.0.0", + "ansis": "4.0.0-node10", .. }Test pm2 with
4.0.0-node10in Node.js 10Run from pm2 project directory:
Output:
