3

enter image description here

Everytime I create React app and start the development server, I get this error. HELP!!!

8
  • can you clarify when exactly this error appears? is this occurring for old CRA that you are trying to run? Or does this occur with every new CRA that you create? When you run CRA, do you get any warnings or messages? Commented Jul 3, 2021 at 6:38
  • It always occur whenever I create new CRA Commented Jul 3, 2021 at 6:41
  • Can you confirm you are running npx create-react-app [app name] and not npm? Can you also run npm --version to see what version of node you are running? Commented Jul 3, 2021 at 6:44
  • Yes I am exactly running the app using npx create-react-app [app name] and the version for npm is 7.19.1 Commented Jul 3, 2021 at 6:45
  • Hmm. Wanna run npx create-react-app [app name], then run rm -rf node_modules inside the app directory, then re-install the dependencies using npm install? Try that and see if t he app runs. Not sure why CRA is downloading dependencies that don't work. Commented Jul 3, 2021 at 7:12

1 Answer 1

1

Per this issue, it may be a problem with the react-scripts part of your library. So either use a specific, older version of create react app by running :

npx [email protected] my-app

Or by running CRA as is, then modifying your package.json folder so that the react script version is specified.

So after you run CRA, change your package.json file like so:

{
  "name": "myapp",
  ...
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.4.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-scripts": "4.0.1"           // change this line to 4.0.1
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  ...
}

Then make sure you rm -rf node_modules then run npm install to get a fresh install that removes whatever react-scripts came by default so that you use the specific 4.0.1 version.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.