next build stops because of TypeScript errors
How 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.
Fix it fast
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 --noEmit2Match what you see, then jump to its fix
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 402Fix
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 nextConfig3Verify
Run the build again. It should complete, and you keep checking types in CI yourself.
npx next build
npx tsc --noEmitConfirmed by nextjs.org
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.json2Fix
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 nextConfig3Verify
Build again. Errors that came from the relaxed option are gone, others remain visible.
npx next buildConfirmed by nextjs.org
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
TypeScript rejects the authorize function of the Credentials provider
A custom field you return from authorize is missing on the User or Session type
The authorize callback must return either a user object or null.
3 causes, each with a fixWeb apps
The user is undefined inside the NextAuth session callback
session.user.id is undefined
With JWT sessions, NextAuth gives the session callback a token, not a user.
3 causes, each with a fixWeb apps
Upgrading to Next.js 16: middleware becomes proxy, and the other things that break
Missing Required default.js for Parallel Route
Next.js 16 renames middleware.ts to proxy.ts and its exported function to proxy.
6 causes, each with a fixWeb apps
TypeScript cannot resolve import './globals.css' in Next.js
ts(2882)
TypeScript now checks imports like import './globals.css' when noUncheckedSideEffectImports is on, and it finds no type for a CSS file.
2 causes, each with a fixWeb apps
getStaticProps is ignored or rejected in a Next.js project
How to fetch data server-side in the latest Next.js? Tried getStaticProps but it's not running and getting undefined
getStaticProps belongs to the Pages Router.
4 causes, each with a fixWeb apps
Type error after upgrading: params does not satisfy the PageProps constraint
Type '{ params: { id: string; }; }' does not satisfy the constraint 'PageProps'
Since Next.js 15, params and searchParams are Promises, not plain objects.
4 causes, each with a fix