question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot find module 'react-is' - Production build

See original GitHub issue

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.

image

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:14
  • Comments:45 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
neodoncommented, Nov 8, 2021

In case anyone is interested, here is a docker-compose.yml file that reproduces the issue:

version: '3'

services:
  app:
    image: node:16-slim
    ports:
      - '8080:8080/tcp'
    environment:
      NODE_ENV: $NODE_ENV
    command: >-
      bash -c '
        npx create-next-app@latest app --use-npm --with-static-export
        cd app

        # Static export does not work out of the box due to the Image component
        grep -v Image pages/index.js >pages/index.js2 && mv pages/index.js2 pages/index.js

        npx next build
        npx next export

        npx http-server --proxy http://localhost:8080/index.html? out
      '

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 export could detect this problem and warn the user. It would save a lot of time and frustration tracking this down.

6reactions
calbrechtcommented, Nov 8, 2021

Happened to me as well 😂

Make sure NODE_ENV=production while next build instead of NODE_ENV=development.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module react when trying to run npm start
After a week I have finally found a solution. First I tried reinstalling an older versions of node and npm, which did not...
Read more >
Cannot find module 'react' Error in TypeScript | bobbyhadz
To solve the "Cannot find module react or its corresponding type declarations" error, install the module and its type definitions by running the...
Read more >
Fix - Cannot find module 'react' error - Reactgo
The can't find module 'react' error occurs, if you're trying to access a react module that is not currently installed in your project....
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >
Error: Cannot find module 'react' || Solved - YouTube
In this video, we will solve Error : Cannot find module ' react ' in reactjs. #command : npm install --save react react...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found