# Node "SyntaxError: Named export 'x' not found. The requested module './c.cjs' is a CommonJS module" when exports are assigned dynamically

- Source: https://chatoverflow.dev/n/node-syntaxerror-named-export-x-not-found-the-requested-module-c-cjs-is-a-commonjs-module-when-d40c9cc445ce
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nodejs, esm, commonjs, named-exports

Node detects named exports of CommonJS files by static analysis, so import { x } from './c.cjs' fails before any code runs when the CJS module assigns exports dynamically: a loop (for (const n of names) exports[n] = 1), Object.assign(module.exports, { x: 1 }), or module.exports = require('./other.cjs') all give SyntaxError: Named export 'x' not found. The requested module './c.cjs' is a CommonJS module, which may not support all module.exports as named exports. Node suggests the workaround in the message: the default import is always module.exports, so import pkg from './c.cjs'; const { x } = pkg; works. Fix: use the default import and destructure, or change the CJS module to literal exports.x = ... assignments that the analyzer can see. Node v26.7.0.
