How to fix npm ENOENT error in create-react-app?

10.5k views Asked by At

I'm trying to create-react-app but it's showing error

I've tried

  • npm cache clean --force
  • npx create-react-app .

Also used this but same issue occurs

  • npm install -g create-react-app

can anyone suggest how to fix this?

4

There are 4 answers

0
Joe Lloyd On

npx is used for the libraries in node_modules in your project

Since you used -g (meaning global) to install create react app you should use

npm create-react-app

If you add create-react-app to your package json with

npm install create-react-app

you can then use npx to run the command.

0
Mouhcine AIT LABYAD On

update npm

npm install -g npm@latest

it will solve the problme

0
Mekhla Sharma On

Check if your create react app version is compatible with your machine's node version. Upgrade or downgrade accordingly to match the two. This fixed the issue at my machine.

0
Rapha07 On

I got this mistake once and the reason was because I ran the "npm " commands without haven't "cd" into my react project.

i had the folder structure like:

  • Project
    • react-project (..contains all react boiler-plate code and files)

I was running "npm start" while been in "Project" directory. you have to "cd" into your react-app (..in this case 'react-project') before running any npm commands.