next build fails with ERR_MODULE_NOT_FOUND - Works in 11.x but not in 12.x
See original GitHub issueWhat version of Next.js are you using?
12.0.4
What version of Node.js are you using?
17.0.1
What browser are you using?
Chrome
What operating system are you using?
Windows
How are you deploying your application?
next build
Describe the Bug
next build
erros with a Module not found
info - Creating an optimized production build
info - Compiled successfully
> Build error occurred
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\PROG\Issues\issues-nextjs-deepkit\node_modules\@deepkit\type\dist\esm\src\types' imported from C:\PROG\Issues\issues-nextjs-deepkit\node_modules\@deepkit
\type\dist\esm\index.js
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:394:11)
at moduleResolve (node:internal/modules/esm/resolve:915:10)
at defaultResolve (node:internal/modules/esm/resolve:1005:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:475:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:245:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
at link (node:internal/modules/esm/module_job:78:36) {
type: 'Error',
code: 'ERR_MODULE_NOT_FOUND'
}
Expected Behavior
A proper successful build.
To Reproduce
I created a repo with 2 branches and steps.
next 11.x branch : Building correctly next 12.x branch : Building fails
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
next build fails with webpack error #25276 - GitHub
When attempting to do a build with next build I get the following error. With next 10.2.0, the error does not appear.
Read more >NextJS12 production build errors on module not found
I don't think this is an actual error. This happened to me once. Just try deleting .next folder first and then run npm...
Read more >Errors | Node.js v19.3.0 Documentation
This will not work because the callback function passed to fs.readFile() is called asynchronously. By the time the callback has been called, the...
Read more >Incremental Static Regeneration - Data Fetching - Next.js
Next.js allows you to create or update static pages after you've built your site. Incremental Static Regeneration (ISR) enables you to use static-generation ......
Read more >React Storybook deploy fails during Webpack build - Support
The weird thing is deploying this Storybook used to work just fine. ... Typescript “module not found” error during one ill-fated Netlify deploy,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Adding this to
next.config.js
Fixes this temporarily.
Seems to be related to https://nextjs.org/blog/next-12#es-modules-support-and-url-imports
I’ll try to look more into this.
Here is a related thread: https://github.com/vercel/next.js/discussions/27876
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.