Skip to content
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

Open
1 of 3 tasks
ben221199 opened this issue Oct 13, 2023 · 40 comments
Labels
status: awaiting user response status: needs reproduction this issue needs to provide a repo that reproduces the bug described type: bug code to address defects in shipped code v4 Issues related to the v4 Next.js runtime

Comments

@ben221199
Copy link

ben221199 commented Oct 13, 2023

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?

  • Yes, I am using the app directory

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

None

Your netlify.toml file

`netlify.toml`
[[plugins]]
    package = "@netlify/plugin-nextjs"

[[plugins]]
    package = "@netlify/plugin-sitemap"

    [plugins.inputs]
    exclude = [
        '.next/404.html',
        '.next/404/index.html',
        '.next/500.html',
        '.next/500/index.html',
    ]

Your public/_redirects file

None

Your next.config.js file

`next.config.js`
/** @type {import('next').NextConfig} */
module.exports = {
    i18n: {
        defaultLocale: 'nl',
        locales: ['nl'],
    },
    images: {
        domains: ['cdn.sanity.io'],
    },
    output: 'standalone',
    swcMinify: false,

    async redirects() {
        const sanityRedirects = await fetchSanityRedirects();
        return sanityRedirects;
    },
};

Builds logs (or link to your logs)

None

Function logs

Function logs
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/.next/server/pages/index.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-handler/___netlify-handler.js
- /var/task/___netlify-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:121: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/.next/server/pages/index.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-handler/___netlify-handler.js',
    '/var/task/___netlify-handler.js',
    '/var/runtime/index.mjs'
  ]
}

.next JSON files

None

@ben221199 ben221199 added the type: bug code to address defects in shipped code label Oct 13, 2023
@ben221199
Copy link
Author

It seems that it will fail when next/head is imported during preview mode.

@popmatik
Copy link

I'm also getting the error when deployed to Vercel.

This is not whilst using preview mode, just standard browsing of the site.

@bkochendorfer
Copy link

I encountered the same issue and was able to work around this for now by downgrading and pinning my application to "next": "13.4.8".

@pcastr0
Copy link

pcastr0 commented Oct 21, 2023

@bkochendorfer thanks! this works! will use this version for now..

@DanielBiegler
Copy link

Can confirm @bkochendorfer 's suggestion works. Downgrading is the way to go for now. Thank you so much!

@dsteenburgh-navan
Copy link

dsteenburgh-navan commented Oct 24, 2023

Having this issue with preview mode off.

  • @netlify/plugin-nextjs version 4.37.1
  • next version 13.5.6

I was able to work around this by downgrading to NextJS 13.4.12. I did not try any other version combinations.

Error from Netlify Logs
ERROR	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

@kdmcguire
Copy link

kdmcguire commented Oct 24, 2023

Same problem here.

  • Not working: @netlify/plugin-nextjs@4.41.1 & next@13.5.6
  • Working: @netlify/plugin-nextjs@4.41.1 & next@13.4.19

The full error message from our function log:

Oct 24, 02:53:01 PM: 6b47ed99 ERROR  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/.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-handler/___netlify-handler.js
- /var/task/___netlify-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/.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-handler/___netlify-handler.js',
    '/var/task/___netlify-handler.js',
    '/var/runtime/index.mjs'
  ]
}

@laurent-le-graverend
Copy link

Got the same issue here, with Next v14. Downgrading to Next v13.4.19 solves the issue for now.

@justynspooner
Copy link

We're having a similar issue and we're not using preview mode. It appears to happen on pages that use getServerSideProps and import Head from 'next/head';

Not working: @netlify/plugin-nextjs@4.41.1 & next@13.5.6
Working: @netlify/plugin-nextjs@4.41.1 & next@13.4.8

ERROR Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'

We have just upgraded to 13 and still use the /pages router if that makes a difference.

@niall-byrne
Copy link

niall-byrne commented Nov 4, 2023

Also seeing this error on deploy to netlify (next14 with pages routing):

Runtime.UnhandledPromiseRejection: Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/amp-context'

Not able to reproduce locally, the file exists in my node_modules directory.
Removing my _document.js file didn't stop the error from occurring.

Running the build inside a minimal Docker container works well as a workaround, no issues with v14.

@eliasm307
Copy link

Im having the same issue

@kai-CuroWork
Copy link

kai-CuroWork commented Nov 6, 2023

Same issue here (also fixed for now by going back down to 13.4.9)

@eliasm307
Copy link

eliasm307 commented Nov 6, 2023

Got the same issue here, with Next v14. Downgrading to Next v13.4.19 solves the issue for now.

This worked for me as a stop gap

@cdking007
Copy link

Downgrading to Next v13.4.19 solves the issue for me also.

@shortcircuit3
Copy link

I had this issue and the only way I could solve it was to move from netlify to vercel :(

@kylekirkby
Copy link

Any idea what is going on here? @Skn0tt

@digeverything
Copy link

I am having a similar error, previewing with Prismic on a NextJS site.

Nov 17, 02:19:27 PM: f4700146 ERROR   ⨯ Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'
Require stack:
- /var/task/node_modules/next/dist/client/script.js
- /var/task/node_modules/next/script.js
- /var/task/node_modules/@prismicio/next/dist/PrismicPreview.cjs
- /var/task/node_modules/@prismicio/next/dist/index.cjs
- /var/task/apps/web/.next/server/pages/api/preview.js
- /var/task/node_modules/next/dist/server/future/helpers/module-loader/node-module-loader.js
- /var/task/node_modules/next/dist/server/future/helpers/module-loader/route-module-loader.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/apps/web/.netlify/functions-internal/___netlify-handler/___netlify-handler.js
- /var/task/___netlify-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/client/script.js:33:42)
    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/client/script.js',
    '/var/task/node_modules/next/script.js',
    '/var/task/node_modules/@prismicio/next/dist/PrismicPreview.cjs',
    '/var/task/node_modules/@prismicio/next/dist/index.cjs',
    '/var/task/apps/web/.next/server/pages/api/preview.js',
    '/var/task/node_modules/next/dist/server/future/helpers/module-loader/node-module-loader.js',
    '/var/task/node_modules/next/dist/server/future/helpers/module-loader/route-module-loader.js',
    '/var/task/node_modules/next/dist/server/next-server.js',
    '/var/task/apps/web/.netlify/functions-internal/___netlify-handler/___netlify-handler.js',
    '/var/task/___netlify-handler.js',
    '/var/runtime/index.mjs'
  ]
}

"@netlify/plugin-nextjs": "^4.41.2"
"next": "^14.0.3",

Fixed it by downgrading to "next": "^13.4.19",

@ericpias
Copy link

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.

@kdmcguire
Copy link

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.

ramicaza pushed a commit to ramicaza/big-agi-query that referenced this issue Nov 22, 2023
@smyja
Copy link

smyja commented Dec 3, 2023

same error for "next": "^13.4.6"

bandrson added a commit to bits-and-bytes-association/bitsandbytesassociation.ca that referenced this issue Dec 17, 2023
@dimitrisnl
Copy link

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.

@vdavid
Copy link

vdavid commented Jan 14, 2024

The bug is still present today. Next 14.0.4. Didn't find a solution.

@patrickhladun
Copy link

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 amp-context module my one with head-manager-context module

Jan 17, 01:39:03 PM: d43a33f1 ERROR  Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'
Require stack:
- /var/task/node_modules/next/dist/client/script.js
- /var/task/node_modules/next/dist/shared/lib/router/router.js
- /var/task/node_modules/next/dist/client/router.js
- /var/task/node_modules/next/router.js
- /var/task/node_modules/nextjs-progressbar/dist/index.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/client/script.js:33:42)
    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/client/script.js',
    '/var/task/node_modules/next/dist/shared/lib/router/router.js',
    '/var/task/node_modules/next/dist/client/router.js',
    '/var/task/node_modules/next/router.js',
    '/var/task/node_modules/nextjs-progressbar/dist/index.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'
  ]
}

@roman-yakobnyuk
Copy link

roman-yakobnyuk commented Jan 18, 2024

Same issue when trying to build using output: "standalone" for any project that uses new @next/third-parties script.

Get the following error on startup:

 Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'

@patrickhladun
Copy link

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.

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 amp-context module my one with head-manager-context module

Jan 17, 01:39:03 PM: d43a33f1 ERROR  Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'
Require stack:
- /var/task/node_modules/next/dist/client/script.js
- /var/task/node_modules/next/dist/shared/lib/router/router.js
- /var/task/node_modules/next/dist/client/router.js
- /var/task/node_modules/next/router.js
- /var/task/node_modules/nextjs-progressbar/dist/index.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/client/script.js:33:42)
    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/client/script.js',
    '/var/task/node_modules/next/dist/shared/lib/router/router.js',
    '/var/task/node_modules/next/dist/client/router.js',
    '/var/task/node_modules/next/router.js',
    '/var/task/node_modules/nextjs-progressbar/dist/index.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'
  ]
}

@popmatik
Copy link

Just to add. I resolved this issue on Vercel by disabling build cache and redeploying.

@martinnabhan
Copy link

Hey everyone. amp-context and head-manager-context are imported dynamically by next/head, which means they won't be properly included in the Netlify function. We can force them to be added by using netlify.toml:

[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.

@oskarhertzman
Copy link

oskarhertzman commented Jan 24, 2024

Hey everyone. amp-context and head-manager-context are imported dynamically by next/head, which means they won't be properly included in the Netlify function. We can force them to be added by using netlify.toml:

[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*",
]

@nolafs
Copy link

nolafs commented Jan 24, 2024

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?

@martinnabhan
Copy link

You need to add the correct path to includes_files. Since you're using a monorepo I guess you have multiple node_modules folders, so you have to add the path to the node_modules folder which contains next.

@ben221199
Copy link
Author

Hey everyone. amp-context and head-manager-context are imported dynamically by next/head, which means they won't be properly included in the Netlify function. We can force them to be added by using netlify.toml:

[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.

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.

@lpalombo
Copy link

Hey everyone. amp-context and head-manager-context are imported dynamically by next/head, which means they won't be properly included in the Netlify function. We can force them to be added by using netlify.toml:

[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.

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.

@SimonPrato11
Copy link

Hey everyone. amp-context and head-manager-context are imported dynamically by next/head, which means they won't be properly included in the Netlify function. We can force them to be added by using netlify.toml:

[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.

This solved the issue, waiting for Netlify final solution

@garvishtayal
Copy link

I encountered the same issue and was able to work around this for now by downgrading and pinning my application to "next": "13.4.8".

Worked for me too changing Next dependency to older version

@dannytlake
Copy link

We are experiencing this issue, running:

  • pnpm
  • Next.js @ ^13.4.6
  • @netlify/plugin-nextjs @ ^4.41.3

Netlify SSR logs for the deploy preview show error
Mar 5, 11:40:14 AM: 97c86c80 ERROR Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/amp-context'

See composable-com/composable-ui#31 for more details

@MarcL MarcL added v4 Issues related to the v4 Next.js runtime and removed Ecosystem: Frameworks labels Mar 13, 2024
@kuji2336
Copy link

@next/third-parties: 14.1.4
next:14.1.0

also can lead this error

⨯ Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'
Require stack:
- /var/task/node_modules/next/dist/client/script.js
- /var/task/node_modules/next/script.js
- /var/task/node_modules/@next/third-parties/dist/google/youtube-embed.js
- /var/task/node_modules/@next/third-parties/dist/google/index.js```

@kuji2336
Copy link

Same issue when trying to build using output: "standalone" for any project that uses new @next/third-parties script.

Get the following error on startup:

 Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'

got same error when using @next/third-parties:^14.1.4 version, did u find a solution?

@wardpeet
Copy link

wardpeet commented Apr 30, 2024

I was able to go around this problem by adding the following to our next.config.js
You might need to specify the file you have in your error message.

        outputFileTracingExcludes: {
          '*': [
            '*/vendored/contexts/amp-context.shared-runtime.js',
          ],
        },

@serhalp
Copy link

serhalp commented Jun 4, 2024

Hi folks!

The team at Netlify have now released the new v5 Next.js runtime which has support for both pages and app router, on-demand and time-based revalidation, automatic fine-grained cache control, and automatic image optimization using Netlify's image CDN.

You can find the documentation and additional information on the new runtime here: Next.js on Netlify

The v4 runtime is now in the maintenance support phase with no new features being added. Occasional bug fixes and security patches will be applied when needed.

Can anyone confirm whether this issue is still occurring with v5 of the runtime and Next.js 13.5+?

@ben221199
Copy link
Author

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.

@serhalp serhalp added status: awaiting user response status: needs reproduction this issue needs to provide a repo that reproduces the bug described labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting user response status: needs reproduction this issue needs to provide a repo that reproduces the bug described type: bug code to address defects in shipped code v4 Issues related to the v4 Next.js runtime
Projects
None yet
Development

No branches or pull requests