next.js: Error: Cannot find module 'react-is' - Production build
What version of Next.js are you using?
12.0.2
What version of Node.js are you using?
16.13.0
What browser are you using?
Chrome
What operating system are you using?
macOS, M1
How are you deploying your application?
next start
Describe the Bug
next dev is working as expected.
When I run next build followed by next run and visit the URL, I get the following error in the console and a large part of the application renders blank.
Expected Behavior
It probably shouldn’t throw this error, unless I’m missing something in my setup.
To Reproduce
There isn’t much more context I can give, I think. I’m not sure if it helps to get my entire package.json but I will of course post it if someone needs it for debugging.
About this issue
- Original URL
 - State: closed
 - Created 3 years ago
 - Reactions: 14
 - Comments: 45 (11 by maintainers)
 
In case anyone is interested, here is a
docker-compose.ymlfile that reproduces the issue:Drop that in a directory by itself, then run
docker-compose up. Open http://127.0.0.1:8080 in your browser and check the console logs after a refresh. There should be no errors.Hit CTRL+C to stop the container. Next, run
NODE_ENV=development docker-compose up. Reloading the page should now show the error in the console.It would be great if
next exportcould detect this problem and warn the user. It would save a lot of time and frustration tracking this down.Happened to me as well 😂
Make sure
NODE_ENV=productionwhilenext buildinstead ofNODE_ENV=development.I managed to resolve the issue that was throwing this error in my project. Documenting here in case it’s useful to anyone following this issue.
The
react-ispackage was moved from “dependencies” to “devDependencies” in Next’s package.json as part of a change published in 12.0.9: https://github.com/vercel/next.js/pull/32742/commits/70822edcdb9b3a281d573ed6fadffa0c4e2b3c4bMy Docker image only contains production dependencies to ensure it’s as small as possible. I use the
yarn --productioncommand in my Dockerfile to ensure devDependencies aren’t installed.Since
react-isis a peerDependency of at least one of the packages I use (styled-components) I needed to ensurereact-isis still available to my application after upgrading to Next 12.0.9. Adding this package to the “dependencies” section of my package.json file resolved the issue.This problem is back in release 12.0.9
NODE_ENV must not be set to
developmentwhile building the app withnext build, probably you would have to clear your .next directory too.For self-hosting, we recommend the official
outputStandalonemode as it can result in an 80% smaller image size in docker deployments:https://nextjs.org/blog/next-12-1#self-hosted-nextjs-improvements
Thanks this resolved the deployment error I was getting in Vercel
This has been released in 12.0.4
Hi, this has been updated in
v12.0.4-canary.10, please update and give it a try!Yes @neodon the screenshot in the original post is from the browser’s console.
When building with Docker I don’t encounter this error, nor with Vercel. We’ve had people with various OSs and Node versions report this issue. So far in this post we’ve had:
No, I’m not.
Same issue here: I found below codes from production chunk:
Node v14.18.1 Nextjs v12.0.2
I just tried creating a fresh new Next project, building and running, and I get the same error! 👀
Steps to reproduce
yarn create next-appyarn buildyarn run