Next Build hangs forever

Viewed 4646

I'm building an app with NextJs and Typescript. I'm trying to run next build (yarn build) on my local machine to check for typescript warnings and build errors before deploying.

Next build hangs at 'Creating an optimized production build' and hangs forever. Don't even know where to start to address this issue. Can anyone help with this?

6 Answers

Could be a cache issue.

I'd start by removing /.next folder, if it didn't work then both /.next and /node_modules. Whenever you have issues with Next you don't know how to approach or it's just acting weird - removing /.next will solve most of the problems.

Have found the solution to the issue. Apparently the build freeze was caused by empty files located all over my project directory. Removed all of them and next build runs

I had the same issue too.

I solved it by upgrading node version from v16.13.0 to v16.14.0.

I solved it downgrading npm version to v8.5.5. I was testing using v8.12.2 and it always keep in "Checking validity of types"

So the issue with it was that I had an empty file somewhere in the app. Apparently the empty file was what was hanging the build

Make sure you stoped all servers that running in the background Use npx kill-port 3000

Related