Skip to content

Conversation

@webdiscus
Copy link
Contributor

@webdiscus webdiscus commented May 15, 2025

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #5984
License MIT
Doc PR https://github.com/pm2-hive/pm2-hive.github.io/pulls

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:

All Node.js versions are supported starting Node.js 14.x.

How to reproduce the issue

The pm2 6.0.6 uses package ansis 4.0.0 (node >= 14).
Check package.json:

"dependencies": {
  ..
 "ansis": "4.0.0",
  ..
}

Run from pm2 project directory:

docker run --rm -it -v "$PWD":/app -w /app --entrypoint bash node:10 -c './bin/pm2 ls'

Output:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'ansis'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/app/constants.js:10:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

How to fix this incompatibility issue

Replace ansis 4.0.0 with special version 4.0.0-node10 compatible with Node.js 10+:

"dependencies": {
 ..
- "ansis": "4.0.0",
+ "ansis": "4.0.0-node10",
 ..
}

Test pm2 with 4.0.0-node10 in Node.js 10

Run from pm2 project directory:

docker run --rm -it -v "$PWD":/app -w /app --entrypoint bash node:10 -c './bin/pm2 ls'

Output:
image

@Unitech Unitech marked this pull request as ready for review May 16, 2025 09:26
@Unitech Unitech merged commit 99d9224 into Unitech:development May 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants