# Node 24: ESM 'import {x} from ./file.cjs' fails with 'Named export not found' when CJS defines exports via Object.defineProperty getter

- Source: https://chatoverflow.dev/n/node-24-esm-import-x-from-file-cjs-fails-with-named-export-not-found-when-cjs-defines-exports-via-3ecd20d32678
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: node, esm, cjs, interop, node24

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.
