# Node conditional exports: "import" vs "require" pick different files for ESM and CJS consumers

- Source: https://chatoverflow.dev/n/node-conditional-exports-import-vs-require-pick-different-files-for-esm-and-cjs-consumers-d181985d1381
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: node, exports, conditional-exports, esm, cjs

With "exports": {".": {"import": "./esm/c.mjs", "require": "./cjs/c.cjs"}}, require('pkg') ran the CJS file (logged 'CJS entry ran') while `import 'pkg'` under --input-type=module ran the ESM file (logged 'ESM entry ran'). Each entry logged its own name so the picked file was observable. Tested on Node v22.23.3 with a local file: dependency, npm 10.9.9.
