Repository navigation
ts-node doesn't work with Typescript 7.0.2 #2174
Copy link
Copy link
Open
Description
Search Terms
Expected Behavior
ts-node should work with Typescript 7.0.2
Actual Behavior
ts-node crashes with the following error message.
It has broken our CI/CD pipeline since 16:00 UTC of 8 July which is exactly when Typescript 7 officially released. And we had to pivot typescript version to 6.0.3 to fix it.
/usr/local/lib/node_modules/ts-node/dist/configuration.js:91
const { fileExists = ts.sys.fileExists, readFile = ts.sys.readFile, skipProject = index_1.DEFAULTS.skipProject, project = index_1.DEFAULTS.project, tsTrace = index_1.DEFAULTS.tsTrace, } = rawApiOptions;
^
TypeError: Cannot read properties of undefined (reading 'fileExists')
at readConfig (/usr/local/lib/node_modules/ts-node/dist/configuration.js:91:33)
at findAndReadConfig (/usr/local/lib/node_modules/ts-node/dist/configuration.js:50:84)
at phase3 (/usr/local/lib/node_modules/ts-node/dist/bin.js:254:67)
at bootstrap (/usr/local/lib/node_modules/ts-node/dist/bin.js:47:30)
at main (/usr/local/lib/node_modules/ts-node/dist/bin.js:33:12)
at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/dist/bin.js:579:5)
at Module._compile (node:internal/modules/cjs/loader:1871:14)
at Object..js (node:internal/modules/cjs/loader:2002:10)
at Module.load (node:internal/modules/cjs/loader:1594:32)
at Module._load (node:internal/modules/cjs/loader:1396:12)
Steps to reproduce the problem
Prerequistics: Debian linux with latest Docker
- In an empty dir, create
Dockerfilewith following content
FROM node:24
RUN npm i -g typescript@7.0.2 ts-node@10.9.2
RUN npx tsc --init
RUN echo "console.log('Hello world')" >> helloworld.ts
CMD ["npx", "ts-node", "helloworld.ts"]
- In the same dir, run
docker container run $(docker image build . -q) - It outputs the error message described above
- The container run also fails if you modify the 2nd line in Dockerfile to
RUN npm i -g ts-node@10.9.2as ts-node pulls the latest Typescript (7.0.2) anyways. - The container runs successfully and outputs
Hello worldif you modify the 2nd line in Dockerfile toRUN npm i -g typescript@6.0.3 ts-node@10.9.2
Minimal reproduction
Specifications
- ts-node version: 10.9.2
- node version: 24.18
- TypeScript version: 7.0.2
- tsconfig.json, if you're using one:
{} *The error above seems to be thrown before loading tsconfig.json
- package.json:
{
"name": "foo",
"version": "1.0.0",
"description": "",
"main": "bar.js",
"author": "",
"license": "ISC",
"dependencies": {
"ts-node": "10.9.2",
"typescript": "7.0.2"
}
}
- Operating system and version: Ubuntu 24 (Confirmed both on WSL2 and Github Actions (Both ARM and X64))
- If Windows, are you using WSL or WSL2?: WSL2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Incompatible with Typescript 7.0.2[/-][+]ts-node doesn't work with Typescript 7.0.2[/+]ClementValot commentedon Jul 10, 2026
Seeing that
ts-nodehas seen low activity recently, I may suggest looking into tsx, which is mentioned in the Node documentation, and can in a lot of cases be a drop-in replacement for ts-node, that is compatible with TS 7.e.g. in my case, I just had to replace
node --test --loader=ts-node/esmwithnode --test --import=tsxbeenotung commentedon Jul 15, 2026
I want to raise out that
tsxis usingesbuildunder the neath, which does not do type-checking, so it is not a drop-in replacement for ts-node (and ts-node-dev).But we may combine it with
tsc --noEmit(with--watchif you need).I still use
ts-nodewhen it doesn't conflict with the project setting, and usetsxotherwise.samchon commentedon Jul 16, 2026
You can use
ttsxinstead: https://github.com/samchon/ttscshivaprabhu commentedon Jul 28, 2026
If you are running Node.js v22.6+, Node can now run .ts files natively out of the box without any third-party loaders
samchon commentedon Jul 28, 2026
https://github.com/samchon/ttsc
Install
ttscand runnpx ttsx src/index.tscommand, then it will work asts-node.Downgrade typescript (see TypeStrong/ts-node#2174)
qasimir commentedon Aug 19, 2026
The root cause is that the Typescript API isn't being supplied until 7.1.X and as such, the official recommendation is to install and use the Typescript 6 API.
I was considering opening a PR myself, but I am really not super familiar with the code, so might take some time,
Likely replacing the code in the attemptRequireWithV8CompileCache() method in util.ts to use typescript 6 compiler
feat(cli): run the TypeScript template with tsx instead of ts-node
feat(cli): run the TypeScript template with tsx instead of ts-node
feat(cli): run the TypeScript template with tsx instead of ts-node
feat(cli): run the TypeScript template with tsx instead of ts-node
feat(cli): move the TypeScript template to tsx and TypeScript 6 (#396)
Update AWS CDK boilerplate
Update AWS CDK boilerplate
Update AWS CDK boilerplate
MazenAhmed2 commentedon Sep 17, 2026
You can make
nodemon.jsonand add to itto use node to execute typescript
nils44344 commentedon Sep 23, 2026
Confirming this, with the version boundary and three workarounds. Tested on Windows 11, Node 24.14.0, ts-node 10.9.2, switching only the TypeScript version between runs:
require('typescript').systs-node src/index.tsobjectlatest)undefinedundefinedThe whole cause in one command:
TypeScript 7 is the Go rewrite, and the npm package is no longer an importable JavaScript library.
ts.sysis gone, soconfiguration.js:91throws while readingtsconfig.json, before any user code is loaded.Two things that surprised me:
--transpileOnlydoesn't help. The config is read before anything is transpiled, so it's the same crash."typescript": ">=2.7", which 7.x satisfies, so a plainnpm installis silent and correct by npm's rules. That's why this reaches projects nobody touched: a fresh clone or a CI cache miss is enough.Workarounds, all verified on the same project:
npm i -D typescript@6.0.3— ts-node works again.npx tsx src/index.ts— tsx doesn't use the compiler API, so TypeScript 7 doesn't affect it.node src/index.ts— on Node 22.18+, Node runs the file itself. No dev dependency, but no type checking either.tscitself is unaffected: TypeScript 7.0.2 compiled the same project with no errors.Minimal reproduction (clone,
npm install,npm run repro): https://github.com/nils44344/node-ts-error-repros/tree/master/04-ts-node-typescript-7fix: downgrade typescript to 5.9.3, add ts-node