Skip to content

ts-node doesn't work with Typescript 7.0.2 #2174

Open

Description

@gosato-netacea

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

  1. In an empty dir, create Dockerfile with 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"]
  1. In the same dir, run docker container run $(docker image build . -q)
  2. It outputs the error message described above
  3. The container run also fails if you modify the 2nd line in Dockerfile to RUN npm i -g ts-node@10.9.2 as ts-node pulls the latest Typescript (7.0.2) anyways.
  4. The container runs successfully and outputs Hello world if you modify the 2nd line in Dockerfile to RUN 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

Activity

  1. changed the title [-]Incompatible with Typescript 7.0.2[/-] [+]ts-node doesn't work with Typescript 7.0.2[/+] on Jul 9, 2026
  2. ClementValot commented on Jul 10, 2026

    @ClementValot

    Seeing that ts-node has 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/esm with node --test --import=tsx

  3. beenotung commented on Jul 15, 2026

    @beenotung

    I want to raise out that tsx is using esbuild under 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 --watch if you need).

    I still use ts-node when it doesn't conflict with the project setting, and use tsx otherwise.

  4. samchon commented on Jul 16, 2026

    @samchon

    You can use ttsx instead: https://github.com/samchon/ttsc

  5. shivaprabhu commented on Jul 28, 2026

    @shivaprabhu

    If you are running Node.js v22.6+, Node can now run .ts files natively out of the box without any third-party loaders

  6. samchon commented on Jul 28, 2026

    @samchon

    https://github.com/samchon/ttsc

    Install ttsc and run npx ttsx src/index.ts command, then it will work as ts-node.

  7. qasimir commented on Aug 19, 2026

    @qasimir

    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

  8. MazenAhmed2 commented on Sep 17, 2026

    @MazenAhmed2

    If you are running Node.js v22.6+, Node can now run .ts files natively out of the box without any third-party loaders

    You can make nodemon.json and add to it

    {
      "execMap": {
        "ts": "node"
      }
    }
    

    to use node to execute typescript

  9. nils44344 commented on Sep 23, 2026

    @nils44344

    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

    1. In an empty dir, create Dockerfile with 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"]
    
    1. In the same dir, run docker container run $(docker image build . -q)
    2. It outputs the error message described above
    3. The container run also fails if you modify the 2nd line in Dockerfile to RUN npm i -g ts-node@10.9.2 as ts-node pulls the latest Typescript (7.0.2) anyways.
    4. The container runs successfully and outputs Hello world if you modify the 2nd line in Dockerfile to RUN 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

    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:

    TypeScript require('typescript').sys exports on the package ts-node src/index.ts
    6.0.3 object 2248 runs
    7.0.2 (current npm latest) undefined 2 crashes
    7.1.0-dev.20260922 undefined 2 crashes

    The whole cause in one command:

    node -p "Object.keys(require('typescript'))"
    # TypeScript 7.0.2 -> [ 'version', 'versionMajorMinor' ]

    TypeScript 7 is the Go rewrite, and the npm package is no longer an importable JavaScript library. ts.sys is gone, so configuration.js:91 throws while reading tsconfig.json, before any user code is loaded.

    Two things that surprised me:

    • --transpileOnly doesn't help. The config is read before anything is transpiled, so it's the same crash.
    • npm can't warn you. ts-node's peer range is "typescript": ">=2.7", which 7.x satisfies, so a plain npm install is 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:

    1. npm i -D typescript@6.0.3 — ts-node works again.
    2. npx tsx src/index.ts — tsx doesn't use the compiler API, so TypeScript 7 doesn't affect it.
    3. node src/index.ts — on Node 22.18+, Node runs the file itself. No dev dependency, but no type checking either.

    tsc itself 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-7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions