4

Everytime I try to create a brand new project with create-react-app I get this error:

Error: Cannot find module 'react-scripts/scripts/init.js'

Screenshot

THE WAY I CREATE PROJECT:

npx create-react-app new-project
node -v v12.13.1
npm -v 6.12.1
OS Win10

already tried:

  • npm uninstall -g create-react-app
  • different project paths

by the way:

  • the problem disappears when I use --use-npm flag

Any ideas what the reason can be?

  • Hey Dean. create-react-app is old now. use npx create-react-app. Have provided the reasons in my answer. Do accept by answer and vote for it, if it is useful to you. That's how new questioners say thanks on Stackoverflow :) – Imran Rafiq Rather Dec 24 '20 at 07:49

4 Answers4

0

Open your command prompt and type "node -v" as well as "npm -v", What do you get there as a response?

Abhay Desai
  • 143
  • 1
  • 8
0

React-scripts issue is issue with webpack and babel mostly. You should create a brand new project using npx create-react-app projectName and this is the recommended approach. This way you don't have to globally install create-react-app in your machine which was previous approach.

Have a look at the documentation. https://reactjs.org/docs/create-a-new-react-app.html

NOTE:

  1. For npx create-react-app projectNameto work. Your node and npm should be: Node >= 8.10 and npm >= 5.6
  2. And you will have to uninstall old create-react-app from the machine. See the doc: https://create-react-app.dev/docs/getting-started
Imran Rafiq Rather
  • 7,677
  • 1
  • 16
  • 35
  • yeah, this is exactly how I do it and get this error – Dean Dimebag Dec 24 '20 at 07:59
  • Did you get error after creating a project using npx create-react-app. If yes thenTry 2 things. – Imran Rafiq Rather Dec 24 '20 at 08:00
  • 1) Check you node version and npm version, they should be Node >= 8.10 and npm >= 5.6 – Imran Rafiq Rather Dec 24 '20 at 08:01
  • 2) Uninstall old global create-react-app from your machine. Here you also need to manually delete some files from C:drive. https://create-react-app.dev/docs/getting-started/#:~:text=If%20you've%20previously%20installed,always%20uses%20the%20latest%20version.&text=Then%20open%20http%3A%2F%2Flocalhost%3A3000%2F%20to%20see%20your%20app. – Imran Rafiq Rather Dec 24 '20 at 08:03
  • Do one thing. Uninstalled node as well. Install a fresh node. Remember manually also delete files from C drive under program files related to node – Imran Rafiq Rather Dec 24 '20 at 08:24
  • 1
    Also may be you have yarn also installed. Just check yarn -v. Since you are saying that --use-npm works . I yarn may be messing the things up. I have encountered this also once. But whatever I did at that time. I already shared with you – Imran Rafiq Rather Dec 24 '20 at 08:26
0

Here i found an answer to the same issue, https://stackoverflow.com/a/63334241/7857368

have your tried creating the app with npx create-react-app myapp you don't need to install the create-react-app globally anymore with this command.

SebMaz93
  • 539
  • 1
  • 6
  • 14
0

Try running the following commands:

npm install
npm install react-scripts
npx create-react-app App-name
ValeriF21
  • 454
  • 1
  • 3
  • 14