Next.js Discord

Discord Forum

Pre-rendering error page error on build?

Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Open in Discord
Australian Freshwater CrocodileOP
#15 26.45 @***/web:build:    Generating static pages (0/4) ...
#15 26.91 @***/web:build: TypeError: Cannot read properties of null (reading 'useContext')
#15 26.91 @***/web:build:     at p (.next/server/pages/_error.js:19:7026)
#15 26.91 @***/web:build: Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
#15 26.91 @***/web:build: TypeError: Cannot read properties of null (reading 'useContext')
#15 26.91 @***/web:build:     at p (.next/server/pages/_error.js:19:7026)
#15 26.91 @***/web:build: Export encountered an error on /_error: /404, exiting the build.
#15 26.93 @***/web:build:  ⨯ Next.js build worker exited with code: 1 and signal: null
#15 26.99 @***/web:build: error: script "build" exited with code 1
#15 27.00 @***/web:build: ERROR: command finished with error: command (/app/apps/web) /usr/local/bin/bun run build exited (1)
#15 27.00 @***/web#build: command (/app/apps/web) /usr/local/bin/bun run build exited (1)



Can’t get my head around this. Seems like I’ve done no big changes to cause this, somewhat just happened. Maybe a dependency upgrade. Let me know if you need more context. This was on build. I don’t use the pages router. No errors in dev.

6 Replies

West African Crocodile
I'm having this after creating a brand new project!!! Did you figure this out @Australian Freshwater Crocodile?
Australian Freshwater CrocodileOP
Still have this issue...
[TypeError: Cannot read properties of null (reading 'useContext')]
Error occurred prerendering page "/404". Read more: [https://nextjs.org/docs/messages/prerender-error](https://nextjs.org/docs/messages/prerender-error)
TypeError: Cannot read properties of null (reading 'useContext')
at exports.useContext (/Users/ted/Documents/Projects/**/node_modules/react/cjs/react.production.js:491:33)
at StyleRegistry (/Users/ted/Documents/Projects/**/node_modules/styled-jsx/dist/index/index.js:450:30)
at renderWithHooks (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:4282:18)
at renderElement (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:4420:14)
at retryNode (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:5022:16)
at renderNodeDestructive (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:4835:7)
at renderElement (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:4769:11)
at retryNode (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:5022:16)
at renderNodeDestructive (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:4835:7)
at renderElement (/Users/ted/Documents/Projects/**/apps/web/node_modules/react-dom/cjs/react-dom-server.edge.production.js:4769:11)
Export encountered an error on /_error: /404, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null
Tan
Did you still encounter this issue? I tried to delete node_modules and package-lock.json, now it works, I'm not sure what's going on. Maybe related to Turborepo dependencies or .npmrc file but not sure.
@Tan Did you still encounter this issue? I tried to delete `node_modules` and `package-lock.json`, now it works, I'm not sure what's going on. Maybe related to Turborepo dependencies or `.npmrc` file but not sure.
Australian Freshwater CrocodileOP
For me it was because I had updated zod to v4… for some reason… instead of using v3… which I don’t think react hook forms works well with… I’m not sure.