Closed Dank-del closed 6 months ago
same
We're experiencing the same issue. Does this occur when the NODE_ENV environment variable is set to "production", or only when it is set to "development" and other custom values?
I am getting this error:
> Export encountered errors on following paths:
/auth-callback/page: /auth-callback
/dashboard/page: /dashboard
And only appears in production while i run the next build
, The error goes when i remove the global hanko instance which is an auth provider i am currently using. The auth-callback and dashboard does uses that instance.
The static page generation is annoying. There should be an option to generate static content on demand instead of at build time.
I have the same issue, static build fails because I use cookies with a JWT everywhere. There really should be a way to opt out of this behaviour
Same, upgraded from 13.4.19 to 13.5.4 and 13.5.6, builds are now failing with the same code.
The error is still present with 14.0.0. I have two custom error pages, one for 404
(not-found.tsx
) and 500
(error.tsx
), but the errors still fail prerendering /404
and /500
(they both display just fine in dev mode):
% pnpm build
> @my-app/app-demo@2.0.0 build /path/to/monorepo/apps/demo
> next build
▲ Next.js 14.0.0
✓ Creating an optimized production build
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
Generating static pages (2/6) [= ]
TypeError: Cannot read properties of null (reading 'useContext')
at exports.useContext (/path/to/monorepo/apps/demo/node_modules/react/cjs/react.production.min.js:24:118)
at Head (/path/to/monorepo/apps/demo/.next/server/chunks/254.js:1:4680)
at Wc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
at Zc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
at bd (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
at Zc (/path/to/monorepo/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 (/path/to/monorepo/apps/demo/node_modules/react/cjs/react.production.min.js:24:118)
at Head (/path/to/monorepo/apps/demo/.next/server/chunks/254.js:1:4680)
at Wc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
at Zc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
at bd (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
at Zc (/path/to/monorepo/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 (/path/to/monorepo/apps/demo/node_modules/react/cjs/react.production.min.js:24:118)
at Head (/path/to/monorepo/apps/demo/.next/server/chunks/254.js:1:4680)
at Wc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
at Zc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
at bd (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
at Zc (/path/to/monorepo/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 (/path/to/monorepo/apps/demo/node_modules/react/cjs/react.production.min.js:24:118)
at Head (/path/to/monorepo/apps/demo/.next/server/chunks/254.js:1:4680)
at Wc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
at Zc (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
at bd (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
at Z (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
at $c (/path/to/monorepo/node_modules/next/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
✓ Generating static pages (6/6)
> Export encountered errors on following paths:
/_error: /404
/_error: /500
ELIFECYCLE Command failed with exit code 1.
same issue here.
It worked for me with 14.0.1
. 🎉
Unfortunately we weren't as lucky as yanickrochon: We upgraded from 13.4.19 to 14.0.1 and stumbled upon pretty similar issues as what Dank-del reported in the initial issue. The same issue also appears with versions 13.5.6 and the latest canary: 14.0.2-canary.21. Specifically, we see the errors for the same 404 and 500 paths as Dank-del (in addition to some of our own paths), but I guess there could still be something wrong with our layout.tsx.
I checked https://nextjs.org/docs/messages/prerender-error but I can't see anything that would apply to our case, specifically:
react
, react-dom
and next-auth
, not sure what other packages it is relevant to upgradegetStaticPaths
or getServerSideProps
export: 'standalone'
in next configAre others still experiencing this issue with next 14.0.1 or later? Is https://github.com/cubik-so/cubik still failing with the newest version?
The error message is the same as what I encountered. The reason my project faced this issue was due to an issue with environment variables. Note that there is this description here:
After trying the command 'NODE_ENV=production next', the build was successful.
Any update on this one?
I downgraded to next 13.2.4 and the issue is fixed. I'll wait for a proper fix here, hoping future versions will fix this.
The NODE_ENV has nothing to do with it in my case, just tried it again with 14.0.2
, same thing...
It tries to generate 19 (!) static pages
And this is building with version 13.4.19
which is correct:
Following up on this issue. Getting an untraceable error with prerendering.
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: o is not a function
at 4187 (/my/little/project/.next/server/chunks/398.js:1:27611)
at t (/my/little/project/.next/server/webpack-runtime.js:1:127)
at 4950 (/my/little/project/.next/server/chunks/398.js:1:37888)
at t (/my/little/project/.next/server/webpack-runtime.js:1:127)
at 265 (/my/little/project/.next/server/chunks/398.js:17:93235)
at t (/my/little/project/.next/server/webpack-runtime.js:1:127)
at 7622 (/my/little/project/.next/server/app/admin/login/page.js:1:3376)
at t (/my/little/project/.next/server/webpack-runtime.js:1:127)
at F (/my/little/project/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:91961)
The error message is the same as what I encountered. The reason my project faced this issue was due to an issue with environment variables. Note that there is this description here:
After trying the command 'NODE_ENV=production next', the build was successful.
For me, the environment variables make a difference. With NODE_ENV=production
, the build runs as expected; however, with NODE_ENV=development
, I get the same error. Unsurprisingly, a non-standard NODE_ENV
can lead to unexpected errors, but it should be working set to development
, as it is widespread to use during testing and development.
The NODE_ENV has nothing to do with it in my case, just tried it again with
14.0.2
, same thing...It tries to generate 19 (!) static pages
And this is building with version
13.4.19
which is correct:
This occurs to me, too. Suddenly, it tries to build many more pages than are present in the source code. Is anyone experiencing this issue using the pages directory, or only the app directory? For my case it occurs with the app dir.
NODE_ENV=production next
I'm getting the same issue with the app dir
I used pages
routing and have the following structure
.
└── root-folder /
├── pages/
│ ├── _app.tsx
│ ├── 404.tsx
│ ├── [...url].tsx
│ ├── page-a.tsx
│ └── page-b.tsx
├── src/
│ ├── app/
│ │ ├── app-provider.tsx
│ │ └── app-config.tsx
│ ├── pages/
│ │ ├── page-a
│ │ └── page-b
│ ├── widgets/
│ │ └── -
│ └── shared/
│ └── ui/
│ └── -
└── next.config.js
Starting with next@^13.5.x
(I think) resolver for 404 pages is broken
Logs:
○ Compiling /[...url] ...
✓ Compiled /[...url] in 16.3s (3611 modules)
○ Compiling /not-found ...
✓ Compiled /not-found in 8s (4062 modules)
When I change src/app
folder name to something another than app
, like app-root
, conflict was done, and
now logs is as expected
○ Compiling /404 ...
✓ Compiled /404 in 6.8s (1491 modules)
I don't know what next.js team introduced, but maybe this can help somehow to resolve error pages existence.
Looks like there was regression introduced here: https://github.com/vercel/next.js/pull/57784
@huozhi ^^
This is even now more of an issue since nextjs 13.4.19 introduced a vulnerability:
Regular Expression Denial of Service (ReDoS) [High Severity][https://security.snyk.io/vuln/SNYK-JS-ZOD-5925617] in zod@3.21.4 introduced by next@13.4.19 > zod@3.21.4
This is solved for me as of 14.0.4-canary.9
It's probably fixed by this PR: https://github.com/vercel/next.js/pull/58609
This is solved for me as of 14.0.4-canary.9
It's probably fixed by this PR: #58609
Not for me
not fixed even in 14th ver., had to downgrade
Really annoying and issue and it overlooks common scenarios (e.g environment variables only available when container is deployed).
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate.
please add a complete reproduction
label?To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository (template for App Router, template for Pages Router), but you can also use these templates: CodeSandbox: App Router or CodeSandbox: Pages Router.
To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.
Please test your reproduction against the latest version of Next.js (next@canary
) to make sure your issue has not already been fixed.
If you cannot create a clean reproduction, another way you can help the maintainers' job is to pinpoint the canary
version of next
that introduced the issue. Check out our releases, and try to find the first canary
release that introduced the issue. This will help us narrow down the scope of the issue, and possibly point to the PR/code change that introduced it. You can install a specific version of next
by running npm install next@<version>
.
Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.
Issues with the please add a complete reproduction
label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.
If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.
Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please do not comment "I have the same issue" without reproduction steps). Then, we can sort issues by votes to prioritize.
We look into every Next.js issue and constantly monitor open issues for new comments.
However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.
Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.
I went through the comments above that seems could caused by different issues, the original reproduction link in the issue is 404 for me. Would be super helpful if anyone can post a reproduction with their specific case which can help us address this issue. Thanks
Hopefully this is relevant: This sandbox demonstrates how upgrading from next@13.4.12 to 13.5.6 prevents the resolving and importing of the 'leaflet.gridlayer.googlemutant' module, which has no dependencies of its own. I have verified that the module exists in node_modules.
(The sandbox uses v13.5.6, so you would need to downgrade to 13.4.12 to see that the issue does not exist in that version.)
@charleskoehl you linked to the official (empty) reproduction template. I'll close this issue as there has been no meaningful activity for over a months since this comment: https://github.com/vercel/next.js/issues/57277#issuecomment-1916527296
If you still experience this issue, please open a new one with an attached reproduction. :pray:
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/cubik-so/cubik
To Reproduce
apps/cubik-web
pnpm install
pnpm build --filter=cubik-web
Current vs. Expected behavior
Current behavior:
Expected behavior: successful build
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router
Additional context
NEXT-2298