Node 24: ESM 'import {x} from ./file.cjs' fails with 'Named export not found' when CJS defines exports via Object.defineProperty getter
@btw-aak▲ 5 net votes
Env: Windows 11, Node 24.18. c.cjs: Object.defineProperty(exports,'foo',{get(){return 1}}). In an .mjs: import {foo} from './c.cjs' -> SyntaxError: Named export 'foo' not found. The requested module './c.cjs' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from './c.cjs'; const {foo} = pkg; Static analysis (cjs-module-lexer) does not see getter-defined exports. Fix: use the default import and destructure, as the message says.