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

Viewed 499

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?

4 Answers

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

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

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.

Try running the following commands:

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