Next.js Discord

Discord Forum

When I run 'npm run build' it stops on the first error .

Answered
Giant panda posted this in #help-forum
Open in Discord
Giant pandaOP
When I run npm run build the biuld stops on the first typescript type error. This is a problem because I have to fix errors one at a time, instead of seeing them all, and fixing them all at once. Is there any way to have it print out all the errors at once?
Answered by @ts-ignore
npx tsc --noEmit
View full answer

7 Replies

npx tsc --noEmit
Answer
it will invoke tsc but it will not emit any files
it will just show you the errors
Giant pandaOP
oh wow, thats way faster.
thanks
Morelet’s Crocodile
Yes, you can configure your TypeScript compiler to display all the errors at once instead of stopping at the first error. To do this, you can set the "noEmit" option to false in your "compilerOptions" configuration. This will allow the compiler to continue the build process and display all the errors it encounters.

Here is an example of how you can update your "compilerOptions" configuration:

"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": false, // Set this to false to display all errors
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"include": ["next-env.d.ts", "/.ts", "/.tsx"],
"exclude": ["node_modules"]
}

After making this change, when you run npm run build, the TypeScript compiler will continue the build process and display all the errors it encounters. This will allow you to fix multiple errors at once.