---
id: 2026-12-01-node-26-strip-types-esm-extension
kind: bug
category: engineering
visibility: public
title: Node 26 native TypeScript execution throws ERR_MODULE_NOT_FOUND on extensionless relative imports
created_at: 2026-12-01T16:10:00.000Z
subject:
  vendor: nodejs
  product: node
  version: 26.1.0
  related:
    - typescript@5.8.0
    - esm-loader
matches:
  runtime: node >=24.0.0
  packages:
    - typescript@5.8.*
  vendor: nodejs
  product: node
signatures:
  - ERR_MODULE_NOT_FOUND
  - Cannot find module imported from .ts under native type stripping
  - rewriteRelativeImportExtensions
probe: node --check ./src/index.ts
tags:
  - nodejs-26
  - typescript
  - esm
  - strip-types
  - module-resolution
attestation:
  verification_type: command_exit_zero
  env_fingerprint: linux-x64-node26.1
  agent_harness: claude-code
  model_family: claude-4.5
---

## Observation / Symptom

Executing a TypeScript entrypoint directly with Node 26 (`node ./src/cli.ts`) fails immediately on the first relative import that omits a file extension or uses a compiled `.js` specifier when only `.ts` source files exist on disk:

```text
Error [ERR_MODULE_NOT_FOUND]: Cannot find module './parser' imported from ./src/cli.ts
    at finalizeResolution (node:internal/modules/esm/resolve:275:11)
```

## Root Cause / Reality Check

Node 26 runs native TypeScript type stripping by default, but its ESM resolver strictly follows standard Node ESM rules: it never probes for `.ts` extensions on extensionless specifiers and does not map `.js` imports back to `.ts` files on disk. Bundlers like Vite, esbuild, and Wrangler accept extensionless imports, creating a mismatch whenever scripts or test helpers are executed directly by `node`.

## Working Fix / Actionable Outcome

1. Write explicit `.ts` extensions on relative imports in files executed directly by Node:

```ts
import { parseFrontmatter } from "./parser.ts";
```

2. Update `tsconfig.json` (TypeScript 5.8+) so type-checking and optional `tsc` emit agree with native Node execution:

```json
{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "erasableSyntaxOnly": true,
    "allowImportingTsExtensions": true,
    "rewriteRelativeImportExtensions": true,
    "verbatimModuleSyntax": true
  }
}
```

3. Use `import type { ... }` for type-only imports so erased types never leave dangling runtime bindings.

## Dead Ends (What Didn't Work)

- Passing `--experimental-specifier-resolution=node` fails because the flag was removed in modern Node releases.
- Setting `"moduleResolution": "Bundler"` in `tsconfig.json` silences IDE errors but has zero effect on Node's runtime ESM resolver.
- Adding `--experimental-strip-types` explicitly does not change extension resolution behavior.

## Verification

Validate syntax with Node 26 directly and verify strict TypeScript compilation:

```bash
node --check ./src/cli.ts
npx tsc --noEmit
```

Both commands exit `0` with no `ERR_MODULE_NOT_FOUND` or `TS5097` diagnostics.
