vercel / next.js

The React Framework
https://nextjs.org
MIT License
121.29k stars 25.96k forks source link

Standalone export broken #65294

Open shimizu-izumi opened 2 weeks ago

shimizu-izumi commented 2 weeks ago

Link to the code that reproduces this issue

https://github.com/shimizu-izumi/broken-standalone-export

To Reproduce

  1. Create a new project using npx create-next-app@latest
  2. Use the following settings: ESLint: Yes Tailwind CSS: Yes src/ directory: Yes App Router: Yes customize the default import alias (@/): Yes import alias: ~/
  3. Set the output to standalone in the next.config.js
  4. Build the project
  5. Start the project using node .next/standalone/server.js

Current vs. Expected behavior

Following the reproduction steps should result in the CSS and JS missing, the expected result would be a fully functional build that misses nothing.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32509
  Available CPU cores: 32
Binaries:
  Node: 20.12.2
  npm: 10.7.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: standalone

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

Output (export/standalone)

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

next start (local), Other (Deployed)

Additional context

No response

shimizu-izumi commented 2 weeks ago

I'm so confused right now. Not only does my linked repo work after cloning it, but a completely new project also works, except for the stuff in the public folder.

LZL0 commented 2 weeks ago

I'm so confused right now. Not only does my linked repo work after cloning it, but a completely new project also works, except for the stuff in the public folder.

Sounds like /node_modules dark magic.

wisdomstar94 commented 2 weeks ago

Exporting to standalone requires several manual tasks.

After proceeding with the build, you have to proceed with the work below.

  1. Move the .next/static folder to .next/standalone/.next/static.
  2. Copy the public folder to .next/standalone/public
  3. Run the node.next/standalone/server.js command.

This way, it will work normally!

shimizu-izumi commented 1 week ago

Exporting to standalone requires several manual tasks.

After proceeding with the build, you have to proceed with the work below.

  1. Move the .next/static folder to .next/standalone/.next/static.
  2. Copy the public folder to .next/standalone/public
  3. Run the node.next/standalone/server.js command.

This way, it will work normally!

Why did the current live version on https://stormywaves.net/ work without that then?

wisdomstar94 commented 1 week ago

@shimizu-izumi

Well, what you want to say is that the css and js files and public resources should be 404 as shown in the image below, but are you saying that it's weird because it works normally? image

shimizu-izumi commented 1 week ago

@wisdomstar94 I'm confused because that 404 thing is why I created this issue but now it works for some reason and the files exist. I don't know why it works now, if it will continue to work, and if I should close this or not.

LZL0 commented 1 week ago

@wisdomstar94 I'm confused because that 404 thing is why I created this issue but now it works for some reason and the files exist. I don't know why it works now, if it will continue to work, and if I should close this or not.

Not sure if that helps, but deleting the .next folder might be a good idea should it stop working.

kasir-barati commented 2 days ago

Hey devs,

I am facing a really weird situation and dunno if it is my mistake or something else is messing with me. Before this commit my NextJS app was OK and no problem. But now even if I comment out every single page\s content and just return a simple <></> (react fragment) it does not build with this odd error:

> nx run frontend:"build:local"

> npx env-cmd -f .env nx build frontend

 NX   Running target build for project frontend and 1 task it depends on:

> nx run @shared:build  [existing outputs match the cache, left as is]

> nx run frontend:build

> next build

 ⚠ You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
  ▲ Next.js 14.2.3
  - Experiments (use with caution):
    · outputFileTracingRoot

   Creating an optimized production build ...
 ✓ Compiled successfully
   Skipping linting
   Checking validity of types ...
   Collecting page data ...
   Generating static pages (0/6) ...
Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
    at Z (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js:16:5430)
    at I (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/135.js:6:1263)
    at renderWithHooks (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16)
    at renderIndeterminateComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5731:15)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5946:7)
    at renderNodeDestructiveImpl (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6104:11)
    at renderNodeDestructive (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6076:14)
    at finishClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5688:3)
    at renderClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5696:3)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5943:7)

Error occurred prerendering page "/500". Read more: https://nextjs.org/docs/messages/prerender-error

Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
    at Z (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js:16:5430)
    at I (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/135.js:6:1263)
    at renderWithHooks (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16)
    at renderIndeterminateComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5731:15)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5946:7)
    at renderNodeDestructiveImpl (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6104:11)
    at renderNodeDestructive (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6076:14)
    at finishClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5688:3)
    at renderClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5696:3)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5943:7)
   Generating static pages (1/6) 
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908) {
  digest: '4259287000'
}
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
   Generating static pages (2/6) 
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908) {
  digest: '4259287000'
}
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)

Error occurred prerendering page "/shop". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908) {
  digest: '4259287000'
}
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)

Error occurred prerendering page "/sign-up". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
   Generating static pages (4/6) 
Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
    at Z (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js:16:5430)
    at I (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/135.js:6:1263)
    at renderWithHooks (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16)
    at renderIndeterminateComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5731:15)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5946:7)
    at renderNodeDestructiveImpl (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6104:11)
    at renderNodeDestructive (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6076:14)
    at finishClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5688:3)
    at renderClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5696:3)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5943:7)

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error

Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
    at Z (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js:16:5430)
    at I (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/135.js:6:1263)
    at renderWithHooks (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16)
    at renderIndeterminateComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5731:15)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5946:7)
    at renderNodeDestructiveImpl (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6104:11)
    at renderNodeDestructive (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6076:14)
    at finishClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5688:3)
    at renderClassComponent (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5696:3)
    at renderElement (/home/kasir/projects/you-say/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5943:7)
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908) {
  digest: '4259287000'
}
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)

Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:109363)
    at d (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:21494)
    at g (/home/kasir/projects/you-say/apps/frontend/.next/server/chunks/743.js:1:13413)
    at au (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:10446)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:15122
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
    at a_ (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:49776)
    at ab (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:11808)
    at /home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16871
    at aw (/home/kasir/projects/you-say/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:16908)
 ✓ Generating static pages (6/6)

> Export encountered errors on following paths:
        /_error: /404
        /_error: /500
        /_not-found/page: /_not-found
        /page: /
        /shop/page: /shop
        /sign-up/page: /sign-up
Warning: command "next build" exited with non-zero status code

 NX   Running target build for project frontend and 1 task it depends on failed

Failed tasks:

- frontend:build

Hint: run the command with --verbose for more details.

Warning: command "npx env-cmd -f .env nx build frontend" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target build:local for project frontend (16s)

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]

And I am pretty confused as why it is happening. My next.config.js is trying to export this app as an standalone app which was working until a few days ago and now it is busted.

I am really frustrated and dunno even where to start to dig for possible corpses :sob:. libs versions:

next: 14.2.3
react: 18.2.0
@nx/next: 19.0.2
nx: 19.0.2
typescript: 5.4.3
node: 22.1.0

Any suggestion?