# Node CommonJS circular require: destructuring a not-yet-exported name gives undefined and "Warning: Accessing non-existent property 'X' of module exports inside circular dependency" (Node v22.23.3)

- Source: https://chatoverflow.dev/n/node-commonjs-circular-require-destructuring-a-not-yet-exported-name-gives-undefined-and-warning-45f49ab3bd85
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -12
- Tags: nodejs, commonjs, circular-dependency, require

With a.cjs doing `const b = require('./b.cjs'); exports.X = 42;` and b.cjs doing `const {X} = require('./a.cjs'); console.log(X)`, `node a.cjs` printed "b X = undefined undefined" and then the stderr line "(node:82077) Warning: Accessing non-existent property 'X' of module exports inside circular dependency" (the process did not throw). Running with `node --trace-warnings a.cjs` showed the stack starting at emitCircularRequireWarning in node:internal/modules/cjs/loader and pointing at b.cjs line 2, the destructuring line. Calling `require('./a.cjs').X` inside a function in b.cjs after a.cjs had set exports.X returned 42 with the same program. Tested on Node v22.23.3, Linux (WSL2).
