Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

next build stops because of TypeScript errors

ErrorHow to disable typescript for failing my builds with nextjs?

Short answer

next build runs a TypeScript check and fails the build when it finds type errors. The proper fix is to correct the errors. If you must ship first, point the build at a looser tsconfig with typescript.tsconfigPath, or set typescript.ignoreBuildErrors to true, which skips the check completely. Run tsc --noEmit in CI so errors do not go unseen.

  • Applies to Next.js 15, Next.js 16, TypeScript 5
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run the type checker on its own. It prints the same errors the build stops on, without the rest of the build.

    npx tsc --noEmit
  2. 2Match what you see, then jump to its fix

    1. 1next build prints a Type error with a file name and line, then exits with a non-zero code.Real type errors in the projectFix
    2. 2Errors come from test files, shared packages in a monorepo, or from a strict option such as useUnknownInCatchVariables.The build checks more strictly than you needFix

What does the error look like?

  • How to disable typescript for failing my builds with nextjs?

Cause 1 of 2

Real type errors in the project

1Check

Next.js fails the production build when TypeScript errors are present. Running tsc --noEmit shows the full list so you can see whether it is one file or many.

npx tsc --noEmit | head -n 40

2Fix

Fix the listed errors. If you cannot fix them today, set typescript.ignoreBuildErrors to true. This skips the type-check step entirely; it does not run TypeScript and hide the messages. Treat it as temporary.

// next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  typescript: {
    ignoreBuildErrors: true,
  },
}

export default nextConfig

3Verify

Run the build again. It should complete, and you keep checking types in CI yourself.

npx next build
npx tsc --noEmit

Confirmed by nextjs.org

Did this fix it?

Cause 2 of 2

The build checks more strictly than you need

1Check

next build type-checks with the tsconfig you pass it. Compare the strict options in tsconfig.json with what the failing files actually need.

grep -n "strict\|useUnknownInCatchVariables\|include" tsconfig.json

2Fix

Create a second config that extends the first and relaxes only the failing option, then give Next.js that file for production builds. Your editor keeps reading tsconfig.json and stays strict.

// tsconfig.build.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "useUnknownInCatchVariables": false
  }
}

// next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  typescript: {
    tsconfigPath: 'tsconfig.build.json',
  },
}

export default nextConfig

3Verify

Build again. Errors that came from the relaxed option are gone, others remain visible.

npx next build

Confirmed by nextjs.org

Did this fix it?

How do I stop it coming back?

  • Run tsc --noEmit as its own CI step so type errors are caught even when ignoreBuildErrors is on.
  • Treat ignoreBuildErrors as a short-term switch and add a note with a date to remove it.
  • Relax a single compiler option in a build tsconfig instead of turning the whole check off.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.