next.js: next build failing after fresh npx create-next-app@latest

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.16.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.5-canary.0
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

build

Link to the code that reproduces this issue or a replay of the bug

no changes done to the code, coming like this without any modification

To Reproduce

install nextjs and install the standard app through “npx create-next-app@latest” √ Would you like to use TypeScript with this project? … No √ Would you like to use ESLint with this project? … No √ Would you like to use Tailwind CSS with this project? … No √ Would you like to use src/ directory with this project? … No √ Use App Router (recommended)? … Yes √ Would you like to customize the default import alias? … No

I tried also the nextjs canary version, + 6 lower versions (went down to version 13.1.0, there it fails with some google font issues…) for the next installation itself and the next create-next-app.

Describe the Bug

“next build” as it throws error

I’m trying to get the standard version running. Using VS Code on Windows. I created a new app by running “npx create-next-app@latest” After this I am running “next build” and this is failing. I did not modify anything. For a new joiner like me this is a big frustration.

PS C:\temp\nextjs-testing\my-test-app> next build

  • info Linting and checking validity of types
  • info Creating an optimized production build
  • info Compiled successfully
  • info Collecting page data [ ] - info Generating static pages (0/3)TypeError: Cannot read properties of null (reading ‘useContext’) at exports.useContext (C:\temp\nextjs-testing\my-test-app\node_modules\react\cjs\react.production.min.js:24:118) at Head (C:\temp\nextjs-testing\my-test-app.next\server\pages_error.js:282:44) at Wc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
    at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217) at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:71:145)

Error occurred prerendering page “/404”. Read more: https://nextjs.org/docs/messages/prerender-error TypeError: Cannot read properties of null (reading ‘useContext’) at exports.useContext (C:\temp\nextjs-testing\my-test-app\node_modules\react\cjs\react.production.min.js:24:118) at Head (C:\temp\nextjs-testing\my-test-app.next\server\pages_error.js:282:44) at Wc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217) at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:71:145) TypeError: Cannot read properties of null (reading ‘useContext’) at exports.useContext (C:\temp\nextjs-testing\my-test-app\node_modules\react\cjs\react.production.min.js:24:118) at Head (C:\temp\nextjs-testing\my-test-app.next\server\pages_error.js:282:44) at Wc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217) at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:71:145)

Error occurred prerendering page “/500”. Read more: https://nextjs.org/docs/messages/prerender-error TypeError: Cannot read properties of null (reading ‘useContext’) at exports.useContext (C:\temp\nextjs-testing\my-test-app\node_modules\react\cjs\react.production.min.js:24:118) at Head (C:\temp\nextjs-testing\my-test-app.next\server\pages_error.js:282:44) at Wc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217) at $c (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:71:145) TypeError: Cannot read properties of null (reading ‘useContext’) at exports.useContext (C:\temp\nextjs-testing\my-test-app\node_modules\react\cjs\react.production.min.js:24:118) at Html (C:\temp\nextjs-testing\my-test-app.next\server\pages_document.js:719:114) at Wc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
at Xc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:409) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:210) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:74:209) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)

Error occurred prerendering page “/”. Read more: https://nextjs.org/docs/messages/prerender-error TypeError: Cannot read properties of null (reading ‘useContext’) at exports.useContext (C:\temp\nextjs-testing\my-test-app\node_modules\react\cjs\react.production.min.js:24:118) at Html (C:\temp\nextjs-testing\my-test-app.next\server\pages_document.js:719:114) at Wc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
at Xc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:409) at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:210) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
at Zc (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:74:209) at Z (C:\Users\Tim\AppData\Roaming\npm\node_modules\next\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)

  • info Generating static pages (3/3)

Export encountered errors on following paths: / /_error: /404 /_error: /500 PS C:\temp\nextjs-testing\my-test-app>

Expected Behavior

no error when trying to build fresh install / created app through “npx create-next-app@latest”

Which browser are you using? (if relevant)

Not relevant

How are you deploying your application? (if relevant)

No

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 15 (5 by maintainers)

Most upvoted comments

same here