Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of null (reading 'useContext') #67697

Open
official-MKV opened this issue Jul 12, 2024 · 7 comments
Open

TypeError: Cannot read properties of null (reading 'useContext') #67697

official-MKV opened this issue Jul 12, 2024 · 7 comments
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Webpack Related to Webpack with Next.js.

Comments

@official-MKV
Copy link

Link to the code that reproduces this issue

https://github.com/official-MKV/test-reproduction

To Reproduce

  1. npm install
  2. next build

Current vs. Expected behavior

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')

Export encountered errors on following paths:
/_error: /404
/_error: /500
/_not-found
/favicon.ico/route: /favicon.ico
/page: /

Provide environment information

operating system: windows
node version: v20.9.0
next version: 14.2.5
react version: @18.3.1

Which area(s) are affected? (Select all that apply)

Webpack

Which stage(s) are affected? (Select all that apply)

next build (local), Vercel (Deployed)

Additional context

I noticed the error on one of my previous projects after trying to next build, I searched for a solution online, went through everything, there is already an existing issue with this same title, but it was never closed and a conclusive solution was never given.

  1. I deleted my package.json, node_modules, cleared cache and re-installed
  2. I slimmed down my dependencies
  3. I set NODE_ENV=production, saw this solution on youtube
  4. I decided to start all over no dependency, no code, and run next build and the error was till there
@official-MKV official-MKV added the bug Issue was opened via the bug report template. label Jul 12, 2024
@github-actions github-actions bot added the Webpack Related to Webpack with Next.js. label Jul 12, 2024
@vishaldhangar15
Copy link

@official-MKV pls share the video of the exact issue .

@igloo1505
Copy link

igloo1505 commented Jul 17, 2024

Did you ever get around this? I just updated React and react-dom to 18.3.1, and Next to 14.2.5 and this came out of nowhere. I was already using react 18.x and Next 14.x, but this latest update caused every single page to fail to build.

This is part of the output, but the initial part is basically repeated for all of the pages that failed to build:

@d-ii-m-a
Copy link

I encountered a similar issue.

Resolving the problem by downgrading to these specific versions:

    "next": "14.1.1",
    "react": "18.3.1",
    "react-dom": "18.3.1"

@lomocc
Copy link

lomocc commented Aug 15, 2024

I found this error by upgrade from 14.2.4 to 14.2.5.

@dylanngph

This comment has been minimized.

@dylanngph

This comment has been minimized.

@Iris-Ares
Copy link

Iris-Ares commented Aug 26, 2024

this works for me

build --experimental-build-mode `compile`

from #63123 (comment)

@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

7 participants