facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.72k stars 26.86k forks source link

React.js refusing to start. Looked at Stack Overflow, but still not helping. #10366

Open Scatmanfan45 opened 3 years ago

Scatmanfan45 commented 3 years ago

Have MacOSX 10.14.6. Have Node.js version 12.18.1 Following along with this tutorial: https://www.w3schools.com/react/ Everything goes fine until issuing the command: npm start I am running this command in the correct folder. I tried updating npm to the latest version. The version is 6.14.11. I tried running rm -rf node_modules and npm_install to reinstall dependencies. No matter what I've tried, I still keep getting this aggrevating error:

sh: react-scripts: command not found npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file sh npm ERR! errno ENOENT npm ERR! myfirstreact@0.1.0 start: react-scripts start npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the myfirstreact@0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/jackgambrell/.npm/_logs/2021-01-12T05_32_04_515Z-debug.log

What should I do?

harshit-prajapati commented 3 years ago

Your environment is probably missing react-scripts. To install them globally give the following command -

npm install -g react-scripts

If the issue still persists, delete the node_modules folder and then give the 'npm install -g npm@latest' command to install all the dependencies again.

Scatmanfan45 commented 3 years ago

Thanks, that seemed to get it to ork! I really appreciate your help. What worked was using sudo before each command. I'm not sure why you need to use sudo? But so glad to get this working!

harshit-prajapati commented 3 years ago

While working in macOS and Linux you need to include sudo before the npm command.

Tip: Use Yarn instead of NPM while creating a react environment to save time.