相关文章推荐

Netlify URL: https://naughty-varahamihira-fcffe0.netlify.app/
Github repo: GitHub - GabZanMacaw/napoleontest
Vercel URL (same project, working): https://napoleontest.vercel.app/

Background:
I had just updated privacy policy and cookie policy pages. I accidentally used “a” instead of “link” and put a “script” tag in the “_document.tsx” file, which apparently doesn’t work. Got a normal build error. After fixing those issues, the build error went away, the deploy was successful, but now this error pops up when you try to go to the website:

"errorType": "Error", "errorMessage": "Cannot find module '/var/task/.next/server/middleware-manifest.json'\nRequire stack:\n- /var/task/node_modules/next/dist/server/next-server.js\n- /var/task/.netlify/functions-internal/___netlify-odb-handler/handlerUtils.js\n- /var/task/.netlify/functions-internal/___netlify-odb-handler/___netlify-odb-handler.js\n- /var/task/___netlify-odb-handler.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js", "trace": [ "Error: Cannot find module '/var/task/.next/server/middleware-manifest.json'", "Require stack:", "- /var/task/node_modules/next/dist/server/next-server.js", "- /var/task/.netlify/functions-internal/___netlify-odb-handler/handlerUtils.js", "- /var/task/.netlify/functions-internal/___netlify-odb-handler/___netlify-odb-handler.js", "- /var/task/___netlify-odb-handler.js", "- /var/runtime/UserFunction.js", "- /var/runtime/index.js", " at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)", " at Function.Module._load (internal/modules/cjs/loader.js:746:27)", " at Module.require (internal/modules/cjs/loader.js:974:19)", " at require (internal/modules/cjs/helpers.js:93:18)", " at NextNodeServer.getMiddlewareManifest (/var/task/node_modules/next/dist/server/next-server.js:600:20)", " at new Server (/var/task/node_modules/next/dist/server/base-server.js:128:40)", " at new NextNodeServer (/var/task/node_modules/next/dist/server/next-server.js:74:9)", " at getBridge (/var/task/.netlify/functions-internal/___netlify-odb-handler/___netlify-odb-handler.js:46:28)", " at handler (/var/task/.netlify/functions-internal/___netlify-odb-handler/___netlify-odb-handler.js:75:46)", " at Runtime.handler (/var/task/node_modules/@netlify/functions/dist/lib/builder.js:41:25)"

I have no idea what that means, and it seems to be specific to Netlify since the exact same project works on Vercel. We can’t use Vercel though.

What I tried:

  • Searching around, no mention of this error.
  • Redeploy with cleared cache, same error.
  • Revert all my changes to last working commit, same error.
  • Creating a new, clean Netlify integration and new repository, same error.
  • Details:

  • Works on local dev server, and on Vercel.
  • Project needs only one environment variable for the Strapi API URL, which I can’t share… if it’s strictly necessary for you I’ll make a copy.
  • Website uses no serverless functions.
  • Does anyone know what is going on??

    hi there, how weird! i will try and see if i can get someone with more next experience to take a look.

    which next version are you using, i wonder?

    also you mentioned that you can’t use vercel - i’m curious whether that’s due to a platform limitation or some other reason? thanks!

    Hi, thanks for the response! Yeah, it is super weird.
    I’m using next 11.0.0 and react 17.0.2.

    As on why we can’t use Vercel, our client already has a different project by another company hosted on Vercel with the same domain. You can’t have two different accounts with the same domain, and they won’t give us access to their Vercel account, so the solution we found is to host it on Netlify instead.

    ### Summary It appears that for a site that's not using Middlewares at all, we'

    Same here!

    This error just happens in the Netlify build.

    It looks to be an issue of incompatibility of next 11.0.0 (or older) with new versions of netlify plugins.
    you can read more in this github issue: [Bug]: Updating plugin to v4 causes 502 error on some routes · Issue #1103 · netlify/next-runtime · GitHub

    We have the same exact problem. We can’t build our NextJS website on Netlify. It works perfectly fine on Vercel. On Netlify the error is: Error - Cannot find module ‘/var/task/.next/server/middleware-manifest.json’

    Unfortunate. We would like to use Netlify, but can’t get it to build b/c of this errors. We don’t even use middleware.

    So, actually it seems like a requirement to use Next 12 on Netlify when it’s a new build. This was our problem. We upgraded, fixed some of incompatibilities with Next12 (NextImage is slightly different), and were able to build. i think you need to put this in your docs somewhere that Next 12 is required.

     
    推荐文章