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?

1
  • 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 :) Commented Dec 24, 2020 at 7:49

4 Answers 4

0

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

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

2 Comments

v12.13.1, 6.12.1
Ok, this means your node is installed correctly which is required for "npm" as well as "react". Try to execute command "npx create-react-app appname"
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.

Comments

0

Try running the following commands:

npm install
npm install react-scripts
npx create-react-app App-name

Comments

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

6 Comments

yeah, this is exactly how I do it and get this error
Did you get error after creating a project using npx create-react-app. If yes thenTry 2 things.
1) Check you node version and npm version, they should be Node >= 8.10 and npm >= 5.6
2) Uninstall old global create-react-app from your machine. Here you also need to manually delete some files from C:drive. create-react-app.dev/docs/getting-started/….
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
|

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.