Skip to content

ERR_UNKNOWN_FILE_EXTENSION since Node.js 18.19.0 (works fine with 18.18.2) #2094

@mlenkeit

Description

@mlenkeit

Search Terms

  • ERR_UNKNOWN_FILE_EXTENSION
  • Node.js 18.19.0
  • Node.js 18.18.2

Expected Behavior

npx ts-node <script.ts> works on Node.js 18.19.0 just as it does with 18.18.2.

Actual Behavior

Since the upgrade to Node.js 18.19.0, the call fails with ERR_UNKNOWN_FILE_EXTENSION.

All other potentially related parameters remained unchanged (e.g. package-lock.json, ts-config.json, etc.).

We discovered this with GitHub workflow runs that run periodically (with schedule) at short intervals; only difference since things started failing is the Node.js version.

Steps to reproduce the problem

  • set up Node.js 18.19.2
  • set "type": "module" in package.json
  • set "esm": true in tsconfig.json
  • create main.ts with something like: console.log('Hello world')
  • run npx ts-node main.ts

Minimal reproduction

see https://github.com/mlenkeit/ts-node-repro

there's also a GitHub workflow to run this repo against Node.js 18.19.0 and 18.18.2:
https://github.com/mlenkeit/ts-node-repro/actions/runs/7057725777

Specifications

  • ts-node version: v10.9.1
  • node version: v18.19.0
  • TypeScript version: v5.2.2
  • tsconfig.json, if you're using one:
    {
      "extends": "@tsconfig/node18/tsconfig.json",
      "ts-node": {
        "esm": true
      },
      "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "moduleResolution": "Node",
        "module": "ESNext",
        "noImplicitAny": false,
        "strictNullChecks": true,
        "sourceMap": true,
        "outDir": "./dist",
        "resolveJsonModule": false,
        "types": [
          "node"
        ]
      },
      "exclude": ["node_modules"]
    }
    
  • package.json:
    {
      "name": "ts-node-repro",
      "private": true,
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "type": "module",
      "dependencies": {
        "@tsconfig/node18": "18.2.2",
        "@types/node": "18.16.1",
        "ts-node": "10.9.1",
        "typescript": "5.2.2"
      }
    }
    
  • Operating system and version: macOS Sonoma 14.1.1

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