Search code examples
node.jsreactjsnpmcreate-react-appreact-bootstrap

npm error: Cannot find module '.../immer.js' when building a create react app through CLI


I am trying to build a website using create react app and bootstrap. We are hosting the site via GH-pages and our repository is here. I have not had issues deploying the site locally until today, but have not yet been able to solve the problem after many hours.

I will go through the steps I performed to get me to where I am at.

  1. Cloned repository through GH Desktop
  2. Opened terminal and input brew reinstall node
  3. Moved to project directory and input npm install react-bootstrap [email protected] and npm install
  4. Finally input npm start

I was met by this:

Command Line response to npm start while in project folder

When I look in '.../node_modules/immer/dist', I see it contains 'immer.d.ts'. Further, when I look in '.../node_modules/react-dev-utils', 'immer.js' is present. I do not know much about Typescript, but the "main" entry looks like it is present, and the files are all present:

immer in node_modules

immer in react-dev-utils

I have uninstalled and reinstalled the package manager, repository all day. I even reset my terminal and text editor to test it on a fresh reboot. I have gone through many StackOverflow questions and done things such as removing only the node_modules and package_lock.json files then inputting npm install, with no success.

Does anyone know what is missing? What should I do?

UPDATE The problem with the 'immer' file was fixed by following the steps provided in the response: clearing the cache, updating the repository, getting a fresh clone, removing the damaged files, and installing npm.

After following these steps, the terminal returned this issue. I have tried troubleshooting this one as well, but feel like I am going in circles. Any directed advice helps.

Error returned after fixing the last one


Solution

  • This problem was solved with

    npm install --legacy-peer-deps
    

    Shoutout to this Stack Overflow answer