Repository navigation
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
Open
PaulRichez wants to merge 1 commit into
PaulRichez wants to merge 1 commit into
Conversation
…hing with ERR_REQUIRE_ESM
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does it do?
bin/config-syncfirst checksprocess.features.require_module. On a Node.js that can'trequire()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.nodebecomes^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
chalk5 andinquirer13, which are both ES-module-only. Node.js canrequire()an ES module from 20.19 and 22.12 on; before that it throwsERR_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:ERR_REQUIRE_ESMfromdist/cli/index.js; after, the message above, exit code 1.Lint and integration tests pass locally (Node 22).
Related issue(s)/PR(s)
Fixes #218