Skip to content

fix(cli): require Node.js 20.19+ or 22.12+ and say so instead of crashing with ERR_REQUIRE_ESM - #242

Open
PaulRichez wants to merge 1 commit into
pluginpal:masterfrom
PaulRichez:fix/cli-node-require-esm
Open

PaulRichez wants to merge 1 commit into
pluginpal:masterfrom
PaulRichez:fix/cli-node-require-esm

Conversation

@PaulRichez

Copy link
Copy Markdown

What does it do?

  • bin/config-sync first checks process.features.require_module. On a Node.js that can't require() an ES module, it prints this and exits with code 1:
    config-sync: the CLI needs a Node.js that can require() ES modules: 20.19+ or 22.12+ (current: v20.18.1).
  • engines.node becomes ^20.19.0 || >=22.12.0 <=24.x.x, so npm warns about it on install.

Why is it needed?

The CLI is built as CommonJS and requires chalk 5 and inquirer 13, which are both ES-module-only. Node.js can require() an ES module from 20.19 and 22.12 on; before that it throws ERR_REQUIRE_ESM, as in #218 (Node 20.18.1). Downgrading chalk alone wouldn't be enough: inquirer would fail right after.

Node.js 20 has been end-of-life since April 2026, so raising the minimum seemed simpler than holding both dependencies back. If you'd rather keep the older 20.x releases working, the alternative is chalk 4 + inquirer 8 (both CommonJS); happy to switch the PR to that.

How to test it?

With the plugin built, run node bin/config-sync --help:

  • Node 20.18.1: before, ERR_REQUIRE_ESM from dist/cli/index.js; after, the message above, exit code 1.
  • Node 20.19.6 and 22.23.3: the CLI runs as before.

Lint and integration tests pass locally (Node 22).

Related issue(s)/PR(s)

Fixes #218

This branch has not been deployed

No deployments
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.

CLI doesn't work with node 20

1 participant