-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Unable to build project, Cannot read properties of null (reading 'useContext') #63123
Comments
Might be related with #57277, which was closed due to no re-pro link. |
Suddenly I started catching this error too Example pipeline - https://gitlab.com/shortlink-org/shortlink/-/jobs/6368837674 I've tried leaving 1 blank page, tried different versions of nx/next/etc, checked that the peer dependencies are correct, deleted the cache, and upgraded the NodeJS version to 21.7 - but nothing worked. |
I am having the same issue here |
Looked at the repo https://github.com/zlace/next-build-error.
|
Same kind of issue here, although mine is happening in dev. seems to be coming from serverside. NextJS 14.2.3 with --turbo
|
I get this error in dev all the time on dev server with Next 14.2.0 with Here is the call stack:
|
Ran into this today. Upon investigation discovered that react and react-dom@18.3.1 had been installed, instead of 18.2.0. Reverting to 18.2.0 made the error go away. Obviously no promises, but if anyone else is running into this it might be worth checking. |
My project does still use 18.2.0 and I experience it often so I don't think that's it, at least in my case.. |
check the enviroment: and I fixed it by set NODE_ENV to production |
I have the same issue in development mode, using NextJS 14.2.3 with --turbo. No idea what is causing it. |
Ditto. Perhaps this should be in a separate issue, since the OP is referring to For me, it happens most frequently when I try type in a direct path to a page. In other words, not clicking through the UI to get to a specific page. What I usually do then is go to the root and navigate via the UI. Pain. |
Hmm indeed Justin, maybe we should get this ticket split. One for build and
one for dev with --turbo
…On Fri, May 17, 2024, 16:06 Justin ***@***.***> wrote:
I have the same issue in development mode, using NextJS 14.2.3 with
--turbo. No idea what is causing it.
Ditto. Perhaps this should be in a separate issue, since the OP is
referring to build and not dev. But curious that it's happening both
places.
For me, it happens most frequently when I try type in a direct path to a
page. In other words, not clicking through the UI to get to a specific
page. What I usually do then is go to the root and navigate via the UI.
Pain.
—
Reply to this email directly, view it on GitHub
<#63123 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZXFOJ7B4UFFAMQ2KUFC7TZCYFHVAVCNFSM6AAAAABEP2XO66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJXGY4DQNRSGY>
.
You are receiving this because you commented.Message ID: <vercel/next.
***@***.***>
|
This issue is only comes with --turbo flag. When i don't use turbo-pack i don't face the issue. Seems like the turbo pack has issues with other packages. My versions: |
I solved it. // next.config.js
...
config.resolve.alias = {
...config.resolve.alias,
- react: path.resolve('./node_modules/react'),
'styled-components': path.resolve('./node_modules/styled-components'),
}; We used alias to unify modules' dependencies while using npm link to use react of current project. we set to an alias for react to Seems to work after deleting the alias. May I know why is this occurring only in dev server? |
I don't have any alias' in my next config, but I do have a path set in my
Could that be related? |
Can confirm it happens to me as soon as I build on v14.2.0 anything lower works fine. "next": "14.2.0",
"react": "^18",
"react-dom": "^18", |
Facing this and been scratching my head for hours. What seems to work is to run the build with experimental compile mode.
Related comments/issues regarding this flag: #46544 (comment) Extra info:
I can confirm this run well on my local and production in Vercel. I'm using dynamic rendering anyway since its more of a "CMS" rather than static blog, so this seems fitting in my case. |
If I remove turbo the app is so slow that it is better to get random crashes lol |
For us, this happened when using |
hahaha yeah man without turbo compile time is so slow. |
I'm facing the same issue
I can reproduce it. Changing the authOptions for next-auth while application is running in dev mode triggers the same error everytime. |
Hopefully that will help put someone on the right track to solve it. However, I am not using next-auth, so it's not limited to just that. But it clearly has something to do with changing some code while in dev mode. |
Also: sometimes it happens when opening a link to a different page of the same project in a new tab. |
I was able to fix this in my project! So I'm using next-seo and it's JSON+LD components and the issue was that I forgot adding The error behavior and message are completely counter-intuitive though. Pages worked fine, all components rendered and page looked OK, yet NextJS was returning 500 Internal Server Error in both development and production. Debugging this was as simple as removing certain components from the tree. |
I had the exact same issue and this solved it! Thank you |
Reagrding to the original issue, it's erroring because it drops the default webpack config externals and this comment is the right fix. Closing this issue as this general react error could cause by various root cause. Please open a new issue with reproduction of your case, we'd love to help investigate the specific root cause 🙏 |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/zlace/next-build-error
To Reproduce
pnpm dev
works,pnpm build
failshttps://stackblitz.com/edit/github-cmffvl?file=README.md
Current vs. Expected behavior
Should build successfully
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.1.0: Thu Sep 14 23:08:13 PDT 2023; root:xnu-10002.40.63.505.1~3/RELEASE_ARM64_T8112 Binaries: Node: 18.19.1 npm: 10.2.4 Yarn: 1.22.21 pnpm: 8.12.1 Relevant Packages: next: 14.1.3 eslint-config-next: 14.1.1 react: 18.2.0 react-dom: 18.2.0 typescript: 5.4.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Module resolution (CJS / ESM, module resolving)
Which stage(s) are affected? (Select all that apply)
next build (local), Vercel (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: