Skip to content

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

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.0.2 became publicly available. 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 touch tsconfig.json
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions