Skip to content

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

Description

@official-MKV

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    WebpackRelated to Webpack with Next.js.bugIssue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions