Home > Blockchain >  NextJS12 production build errors on module not found
NextJS12 production build errors on module not found

Time:11-30

OS: Windows 10 Node: 16.13.0 NextJS: 12

I just upgraded to nextjs 12 and am now getting Module not found on a next build

This is working fine next -p 3000

But when I run next build things seems to be compiling but right at the end it fails with the following error.

> next build
...

info  - Creating an optimized production build .Warning: 4 repetitive deprecation warnings omitted.

info  - Creating an optimized production build
Failed to compile.

Module not found: Error: Can't resolve './C:/Users/X/AppData/Roaming/npm/node_modules/next/dist/client/next.js' in 'F:\myproject\x\client'

> Build failed because of webpack errors

Since it's complaining about next.js I don't think it has anything to do with any of my other libraries? My application is running fine in nextjs dev mode.

CodePudding user response:

I don't think this is an actual error. This happened to me once. Just try deleting .next folder first and then run npm run build. If that didn't work, try deleting node_modules folder and run npm install again.

CodePudding user response:

Something like happened to me few days ago.

I resolved this issues by,

  1. Delete the node_modules folder
  2. Delete the .next folder
  3. Run the command:
    npm i`and then `npm run build
    
  • Related