Skip to content

Loading nitro.config.ts on Node.js < 2.18 fails with "Unknown file extension .ts" #4364

Description

@meirlamdan

Environment

  • OS: Linux (Cloudflare Pages CI)
  • Node version: 22.16.0
  • Nitro version: 3.0.260610-beta
  • pnpm version: 10.11.1

Reproduction

  1. Create a Nitro v3 project with a nitro.config.ts file
  2. Deploy to Cloudflare Pages with build command vite build
  3. Build fails immediately

Error

Error: Failed to load config file `/opt/buildhome/repo/nitro.config.ts`: Unknown file extension ".ts" for /opt/buildhome/repo/nitro.config.ts.  Hint install `jiti` for compatibility.
    at file:///opt/buildhome/repo/node_modules/.pnpm/nitro@3.0.260610-beta_vite@8.0.16_@types+node@26.0.0_/node_modules/nitro/dist/_libs/c12+rc9.mjs:537:12
...
[cause]: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /opt/buildhome/repo/nitro.config.ts

Root Cause

Nitro v3 lists jiti as an optional peer dependency (peerDependenciesMeta), so it is not installed automatically. In CI environments like Cloudflare Pages, jiti is absent and c12 cannot load nitro.config.ts.

Workaround

Explicitly add jiti to devDependencies:

pnpm add -D jiti

Expected Behavior

Either:

  • jiti should be a regular (non-optional) dependency of Nitro so it is always available, or
  • The documentation / create-nitro-app scaffold should make it clear that jiti must be added manually when using a TypeScript config file

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    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