Fix import statement for Yargs module#581
Open
coderaiser wants to merge 1 commit into
Open
Conversation
`yargs` is ESM, and this file is CommonJS, this is no longer works in node v25
coderaiser
added a commit
to coderaiser/putout
that referenced
this pull request
Feb 24, 2026
This was referenced Feb 26, 2026
7 tasks
|
The issue with the import statement has been fixed in Node 25.8.1, and everything works ⚙️ as before ⏮️ |
|
@bricss That Node 25.8.1 change was reverted in 26.0.0 (nodejs/node@0c08835). $ npx c8 --help
Need to install the following packages:
c8@11.0.0
Ok to proceed? (y) y
file:///home/anders/.npm/_npx/ce601f5be3f19082/node_modules/yargs/yargs:3
const {applyExtends, cjsPlatformShim, Parser, Yargs, processArgv} = require('./build/index.cjs')
^
ReferenceError: require is not defined in ES module scope, you can use import instead
at file:///home/anders/.npm/_npx/ce601f5be3f19082/node_modules/yargs/yargs:3:69
at ModuleJobSync.runSync (node:internal/modules/esm/module_job:543:37)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:353:47)
at loadESMFromCJS (node:internal/modules/cjs/loader:1675:24)
at Module._compile (node:internal/modules/cjs/loader:1838:5)
at Object..js (node:internal/modules/cjs/loader:1996:10)
at Module.load (node:internal/modules/cjs/loader:1579:32)
at Module._load (node:internal/modules/cjs/loader:1381:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at Module.require (node:internal/modules/cjs/loader:1602:12)
Node.js v26.1.0Please merge this one-line fix, it really is required. |
|
@andersk True story, you can use this yargs/yargs#2509 (comment) trick 🎩 to make it work ⚙️ for now. |
6 tasks
andersk
added a commit
to andersk/micromark
that referenced
this pull request
May 16, 2026
Node 25.7.0 broke extensionless CJS scripts in "type": "module" packages, such as yargs/yargs in yargs 17.x imported by c8; this behavior was temporarily rolled back in Node 25.8.1 but is now restored in 26.0.0 and future versions. Until either yargs releases a backported fix for yargs 17.x, or c8 fixes its import statement, or c8 upgrades to yargs 18.x (all three of those efforts have been stalled for months), we need to work around this with an override. yargs/yargs#2509 yargs/yargs#2514 bcoe/c8#582 bcoe/c8#581 bcoe/c8#578 Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk
added a commit
to andersk/micromark
that referenced
this pull request
May 16, 2026
Node 25.7.0 broke extensionless CJS scripts in "type": "module" packages, such as yargs/yargs in yargs 17.x imported by c8; this behavior was temporarily rolled back in Node 25.8.1 but is now restored in 26.0.0 and future versions. Until either yargs releases a backported fix for yargs 17.x, or c8 fixes its import statement, or c8 upgrades to yargs 18.x (all three of those efforts have been stalled for months), we need to work around this with an override. yargs/yargs#2509 yargs/yargs#2514 bcoe/c8#582 bcoe/c8#581 bcoe/c8#578 Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk
added a commit
to andersk/micromark
that referenced
this pull request
May 20, 2026
Node 25.7.0 broke extensionless CJS scripts in "type": "module" packages, such as yargs/yargs in yargs 17.x imported by c8; this behavior was temporarily rolled back in Node 25.8.1 but is now restored in 26.0.0 and future versions. Until either yargs releases a backported fix for yargs 17.x, or c8 fixes its import statement, or c8 upgrades to yargs 18.x (all three of those efforts have been stalled for months), we need to work around this with an override. yargs/yargs#2509 yargs/yargs#2514 bcoe/c8#582 bcoe/c8#581 bcoe/c8#578 Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk
added a commit
to andersk/micromark
that referenced
this pull request
May 20, 2026
Node 25.7.0 broke extensionless CJS scripts in "type": "module" packages, such as yargs/yargs in yargs 17.x imported by c8; this behavior was temporarily rolled back in Node 25.8.1 but is now restored in 26.0.0 and future versions. Until either yargs releases a backported fix for yargs 17.x, or c8 fixes its import statement, or c8 upgrades to yargs 18.x (all three of those efforts have been stalled for months), we need to work around this with an override. yargs/yargs#2509 yargs/yargs#2514 bcoe/c8#582 bcoe/c8#581 bcoe/c8#578 Signed-off-by: Anders Kaseorg <andersk@mit.edu>
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.
yargsis ESM, and this file is CommonJS, this is no longer works in node v25Checklist
npm test, tests passingnpm run test:snap(to update the snapshot)