-
Notifications
You must be signed in to change notification settings - Fork 84
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
[Bug]: Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/amp-context'
in NextJS preview mode
#2329
Comments
It seems that it will fail when |
I'm also getting the error when deployed to Vercel. This is not whilst using preview mode, just standard browsing of the site. |
I encountered the same issue and was able to work around this for now by downgrading and pinning my application to |
@bkochendorfer thanks! this works! will use this version for now.. |
Can confirm @bkochendorfer 's suggestion works. Downgrading is the way to go for now. Thank you so much! |
Having this issue with preview mode off.
I was able to work around this by downgrading to NextJS Error from Netlify LogsERROR Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/amp-context'
Require stack:
- /var/task/node_modules/next/dist/shared/lib/head.js
- /var/task/node_modules/next/head.js
- /var/task/node_modules/next-seo/lib/next-seo.js
- /var/task/.next/server/pages/_app.js
- /var/task/node_modules/next/dist/server/require.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/.netlify/functions-internal/___netlify-odb-handler/___netlify-odb-handler.js
- /var/task/___netlify-odb-handler.js
- /var/runtime/index.mjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at /var/task/node_modules/next/dist/server/require-hook.js:54:36
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at mod.require (/var/task/node_modules/next/dist/server/require-hook.js:62:32)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/var/task/node_modules/next/dist/shared/lib/head.js:29:34)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/var/task/node_modules/next/dist/shared/lib/head.js',
'/var/task/node_modules/next/head.js',
'/var/task/node_modules/next-seo/lib/next-seo.js',
'/var/task/.next/server/pages/_app.js',
'/var/task/node_modules/next/dist/server/require.js',
'/var/task/node_modules/next/dist/server/next-server.js',
'/var/task/.netlify/functions-internal/___netlify-odb-handler/___netlify-odb-handler.js',
'/var/task/___netlify-odb-handler.js',
'/var/runtime/index.mjs'
]
} Edit: Added error message |
Same problem here.
The full error message from our function log:
|
Got the same issue here, with Next v14. Downgrading to Next v13.4.19 solves the issue for now. |
We're having a similar issue and we're not using preview mode. It appears to happen on pages that use Not working: @netlify/plugin-nextjs@4.41.1 & next@13.5.6
We have just upgraded to 13 and still use the /pages router if that makes a difference. |
Also seeing this error on deploy to netlify (next14 with pages routing):
Not able to reproduce locally, the file exists in my node_modules directory. Running the build inside a minimal Docker container works well as a workaround, no issues with v14. |
Im having the same issue |
Same issue here (also fixed for now by going back down to 13.4.9) |
This worked for me as a stop gap |
Downgrading to Next v13.4.19 solves the issue for me also. |
I had this issue and the only way I could solve it was to move from netlify to vercel :( |
Any idea what is going on here? @Skn0tt |
I am having a similar error, previewing with Prismic on a NextJS site.
Fixed it by downgrading to |
I am also seeing a similar deploy only issue on pages that use getServerSideProps and import Head from 'next/head' and add metadata. 500 error. Using page routing and NextJS 14.0.2. Downgrading back to 13.4.8 is a work-around for me. For some reason 13.4.19 did not resolve it for me. |
Hey folks, there's a related discussion going on in Netlify's support forum here: https://answers.netlify.com/t/next-js-14-upgrade-results-in-500-status-code/105786/4 In essence, it sounds like they might be working on an overhaul of how Next.js runs on Netlify* and they'd rather focus on that than keep playing whack-a-mole with the current system, as the rate of Next.js updates encountering problems on Netlify is increasing. *I can't say that for sure, I don't work there, but that's what I inferred from the responses. |
same error for "next": "^13.4.6" |
Since most messages are from November, I wanted to mention that it's still an issue. I upgraded to Next 14 and pages with getServerSideProps, broke with the same error. I see that the issue has been open for 2 months now. I don't mind Vercel making things hard for other providers, but I would like some confirmation or estimate from Netlify. |
The bug is still present today. Next 14.0.4. Didn't find a solution. |
I have a similar issue when deployed to Netlify; locally work fine? I am trying different versions of the next 13 but have had no luck so far. Some have issue with
|
Same issue when trying to build using Get the following error on startup:
|
I found a solution to my problem, and I want to share it with you in case it can help. In my situation, downgrading nextjs to the previous version didn't solve the issue. So, I started to investigate my code. During this process, I was removing third-party code from the _app.js file and discovered that the culprit was the nextjs-progressbar package. I hope this information is useful to someone.
|
Just to add. I resolved this issue on Vercel by disabling build cache and redeploying. |
Hey everyone. [functions]
included_files = [
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/amp-context*",
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context*",
] This solved the issue for me. |
Thanks this worked! In my case, i had to add router-context aswell: [functions]
included_files = [
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/router-context*",
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/amp-context*",
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context*",
] |
Hi, I tried to include the files but it is not working. I am wondering if this has to do with my nx monorepro. Anybody using NX repro and using include_files? |
You need to add the correct path to |
This solved the issue for me too. However, I think this should not be the final solution, so I will wait until Netlify comes up with one. |
Just adding here that with a project using the PNPM package manager. This solution does not appear to work. Probably has something to do with it's virtual file system. |
This solved the issue, waiting for Netlify final solution |
Worked for me too changing Next dependency to older version |
We are experiencing this issue, running:
Netlify SSR logs for the deploy preview show error See composable-com/composable-ui#31 for more details |
also can lead this error
|
got same error when using |
I was able to go around this problem by adding the following to our next.config.js
|
Hi folks! The team at Netlify have now released the new You can find the documentation and additional information on the new runtime here: Next.js on Netlify The Can anyone confirm whether this issue is still occurring with v5 of the runtime and Next.js 13.5+? |
Well, I have to remove the fix that temporary solved this bug. I will try that tomorrow if I get the errors back or not. |
Summary
Website is working normally, but when setting NextJS in preview mode to see live Sanity data, Netlify gives a 500 error. Locally, the preview mode works. Also, in a Docker image it works as expected. Netlify is the only place where preview mode fails.
A link to a reproduction repository
Private repository
Expected Result
No error, just NextJS on Netlify in preview mode getting live data from Sanity.
Actual Result
A 500 error in the browser and the error log below.
Steps to reproduce
Don't know.
Next Runtime version
4.40.3-rc.0
Is your issue related to the
app
directory?app
directoryMore information about your build
netlify.toml
)What OS are you using?
None
Your netlify.toml file
`netlify.toml`
Your public/_redirects file
None
Your
next.config.js
file`next.config.js`
Builds logs (or link to your logs)
None
Function logs
Function logs
.next JSON files
None
The text was updated successfully, but these errors were encountered: