Unable to deploy Nextjs 12 with transpiled packages

  • https://dev-switching.netlify.app/
    I’m trying to set up an existing Nextjs app in Netlify but it won’t build. The same app is deployed in Vercel atm without issues. Builds work fine locally. Why are they failing in Netlify?
1:28:28 PM: error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
1:28:28 PM: > Build error occurred
1:28:28 PM: Error: next-transpile-modules - an unexpected error happened when trying to resolve "survey". Are you sure the name of the module you are trying to transpile is correct, and it has a package.json with a "main" or an "exports" field?
1:28:30 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:28:28 PM: Error: Can't resolve 'survey/package.json' in '/opt/build/repo/apps/switching'
    at getPackageRootDirectory (/opt/build/repo/node_modules/next-transpile-modules/src/next-transpile-modules.js:128:15)
1:28:28 PM:     at Array.map (<anonymous>)
1:28:28 PM:     at withTM (/opt/build/repo/node_modules/next-transpile-modules/src/next-transpile-modules.js:137:34)
1:28:28 PM:     at Object.<anonymous> (/opt/build/repo/apps/switching/next.config.js:13:18)
1:28:28 PM:     at Module._compile (node:internal/modules/cjs/loader:1165:14)
1:28:28 PM:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
1:28:28 PM:     at Module.load (node:internal/modules/cjs/loader:1043:32)
1:28:28 PM:     at Function.Module._load (node:internal/modules/cjs/loader:878:12)
1:28:28 PM:     at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
1:28:28 PM:     at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
1:28:28 PM: npm ERR! Lifecycle script `build` failed with error:
1:28:28 PM: npm ERR! Error: command failed
1:28:28 PM: npm ERR!   in workspace: switching@0.1.0
1:28:28 PM: npm ERR!   at location: /opt/build/repo/apps/switching

My nextjs config and package.json files

If I try to deploy from the CLI everything works fine but I get a Page Not Found when I open the domain.

Hi @boris :wave:t6: ,

Have you given this support guide a read and see if that helps?

I have checked it and it hasn’t helped. I’m more worried about the app not being buildable than the 404 error.

I downloaded the deployment like the guide says and i got ~1GB of files which match what my local build produced. I also have a index.html page there as well as other pages.

Hi @boris,

Please continue the discussion in the ticket 132758 in helpdesk.

How do I do that? How can I access that ticket in the helpdesk?

Can you at least confirm if you do indeed support NextJS apps that are NOT [exported]?(Advanced Features: Static HTML Export | Next.js)

Yes, we support that. Please read: Next.js on Netlify | Netlify Docs