sh: react-scripts: command not found after running npm start

Reactjs

Reactjs Problem Overview


I cloned a react application onto my system and ran following commands

npm install -g create-react-app
npm install --save react react-dom

After that i ran

npm start 

But it threw the above mentioned error, It is working fine on my other system from which i pushed it on github. But it is not working on any other system after cloning whether windows or mac.

Reactjs Solutions


Solution 1 - Reactjs

Check if node_modules directory exists. After a fresh clone, there will very likely be no node_modules (since these are .gitignore'd).

Solution

run npm install (or yarn) to ensure all deps are downloaded.

Alternative Solution

If node_modules exists, remove it with rm -rf node_modules and then run npm install (or yarn).

Solution 2 - Reactjs

Tried all of the above and nothing worked so I used npm i react-scripts and it worked

Solution 3 - Reactjs

I had similar issue. In my case it helped to have Yarn installed and first execute the command

yarn

and then execute the command

yarn start

That could work for you too if the project that you cloned have the yarn.lock file. Hope it helps!

Solution 4 - Reactjs

you should not install react-scripts globally, for me this fixed the problem:

npm install --save react react-dom react-scripts

if this still dont work :

  1. update to latest npm version : npm install -g npm@latest
  2. delete node_modules directory
  3. reinstall all dependencies : npm install

Solution 5 - Reactjs

In package.json, I changed

"start": "react-scripts start"

to

"start": "NODE_ENV=production node_modules/react-scripts/bin/react-scripts.js start"

I hope this solves the problem for some people. Although the other solutions above seem not to work for me.

Solution 6 - Reactjs

https://github.com/facebookincubator/create-react-app

npm install -g create-react-app

create-react-app my-app
cd my-app/
npm start

You install the create-react-app package globally. After that you run it and create a project called my-app. Enter your project folder and then run npm start. If that doesn't work try running npm install and then npm start. If that doesn't work as well, try updating your node version and/or npm.

Solution 7 - Reactjs

I had this problem for ages and I eventually found my solution by sheer chance.
Turns out, you can't have spaces or wacky characters in any folder names.

e.g. ~/projects/tutorial/ReactJS/JavaScript Framework: ReactJS/app-name won't work because JavaScript Framework: ReactJS contains spaces.
In general, it's probably not great practice to be using spaces in folder/file names anyway but I hope this saves someone at least 4 hours of trial and error.

Also, any non-alphanumeric characters should be avoided.

Solution 8 - Reactjs

This error occurs when you Install package with npm install instead of yarn install or vice-versa.

Solution 9 - Reactjs

npm install --save react react-dom react-scripts

Above command worked for me.

Solution 10 - Reactjs

using npm i --legacy-peer-deps worked for me.

I do not know specifically which operation out of the following it performed:

  • Installing the peer dependencies' latest stable version.
  • Installing the peer dependencies' version which the core dependy you are installing uses.

But I think it performs the latter operation. Feel free to let me know if I'm wrong ^-^

Solution 11 - Reactjs

Just ran into this problem after installing material-ui.

Solved it by simply running npm install again.

Solution 12 - Reactjs

This boggles me time to time when I have a fresh start with create-react-app, please make sure your NODE_ENV variable is set to development not production, as devDependencies in your package.json will not be installed by npm install.

Solution 13 - Reactjs

Just doing an Yarn install solved the problem for me

Solution 14 - Reactjs

If you are having this issue in a Docker container just make sure that node_modules are not added in the .dockerignore file.

I had the same issue sh1 : react scripts not found. For me this was the solution

Solution 15 - Reactjs

Deleting package-lock.json and node_modules then npm install worked for me.

Solution 16 - Reactjs

If none of the other answers work properly (after updating the npm etc). I would strongly recommend you to install the project on your desktop.

create-react-app project_name

Solution 17 - Reactjs

If anyone still have this problem after trying these solutions: check your project path as node has some issues working with spaced dir names. I changed all directories names that had spaces in their names and it worked perfectly.

solution idea taken from: https://npm.community/t/react-scripts-not-found/8574

i am using yarn BTW

Solution 18 - Reactjs

You shoundt use neither SPACES neither some Special Caracters in you path, like for example using "&". I my case I was using this path: "D:\P&D\mern" and because of this "&" I lost 50 minutes trying to solve the problem! :/

Living and Learning!

Solution 19 - Reactjs

If you have tried everything and nothing solved it, try to rename the directories name. react will not start if the folder's name contains uppercase letters.

Solution 20 - Reactjs

I just randomly experienced this "react-scripts: command not found" error after issuing a react-scripts build request, which was previously working just fine.

A simple reboot of my system corrected the issue.

Solution 21 - Reactjs

if anyone is willing to use npm only, then run this npm i react-native-scripts --save, then npm start or whatever the command you use

Solution 22 - Reactjs

solution 1:

delete the package-lock.json file and then type -> npm install

solution 2:

>/Users/piyushbajpai/.npm/_logs/2019-03-11T11_53_27_970Z-debug.log

like this is my debug path --> so this you will find in the console -> press on command and click on the link, you will find error line; like this: > verbose stack Error: [email protected] start: react-scripts start

solution 3:

delete the node_module and npm i with fresh way.

solution 4:

go to node_module and delete jses folder and delete it, then do npm i and again start with npm start

Solution 23 - Reactjs

I had issues with latest version of yarn 1.15.1-1

I've fixed it by downgrading to lower version sudo apt-get install yarn=1.12.3-1

Solution 24 - Reactjs

The solution that worked for me is below. Try creating React app with this command.

create-react-app react-app --scripts-version 1.1.5

Solution 25 - Reactjs

I ran into this error after renaming the directory with the @/ symbol on macOS to match the name of my NPM package namespace.

When the NPM command looked for installed packages in my local node_modules, it couldn't find it due to the way macOS was rewriting the directory path. After renaming the directory without @/ I was up and running again.

Solution 26 - Reactjs

Just You have to restore packages to solve this issue, So just run command :

npm install or yarn install

Solution 27 - Reactjs

this worked for me.

if you're using yarn:

  1. delete yarn.lock
  2. run yarn
  3. and then yarn start

if you're using npm:

  1. delete package-lock.json
  2. run npm install
  3. and then npm start

Solution 28 - Reactjs

If the above solutions don't work and you saw the below error:

npm ERR! The operation was rejected by your operating system.

npm ERR! It is likely you do not have the permissions to access this file as the current user

try with sudo npm install

Solution 29 - Reactjs

I tried every answer but cleaning my npm cache worked..

steps:

  1. Clean cache =====> npm cache clean force.
  2. reinstall create-react-app =====> npm install create-react-app.
  3. npm install.
  4. npm start !!!

Solution 30 - Reactjs

For me it was deleting package-lock.json and node_modules and then run npm install again.

Solution 31 - Reactjs

just run these commands

npm install
npm start

or

yarn start

Hope this will work for you thank you

Solution 32 - Reactjs

None of these solutions worked for me. I found that the problem was the directory I was creating the project in, I am not sure why but when I created the project outside of that directory it worked. My solution was changing the directory to a new one from "React/Ionic" to "ionic-react". It could be that not only the project itself should be lowercase, but its parent folder as well, or it could be that the "/" in the directory name be the issue. Hope this helped.

Solution 33 - Reactjs

fixed it with

npm install --legacy-peer-deps

If you use npm to install and npm version is less than 7, then its npm most likey to behave in a smarter way. So, it will try to install react with its other depencies(peer deps)(higher versions if found), which will likely to break the library react. Attaching --legacy-peer-deps will tell npm "not to do something new", and install whats given in package.json...

Btw people seem to find yarn comfortable because this "not to install higher version if even found" is built in yarn automatically

reference: A referenced question

Solution 34 - Reactjs

After spending too much time trying all the solutions above, I can say for sure:

If you ran into this issue, check your path. If the path contains any special character or spaces just rename it and make sure that the new path doesn't have any spaces or special character. Then run it again .

Solution 35 - Reactjs

This workaround works for me

// in your package.json replace 
"start": "react-scripts start"

// with:
"start": "node_modules/react-scripts/bin/react-scripts.js start"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDevesh JadonView Question on Stackoverflow
Solution 1 - ReactjsDeBraidView Answer on Stackoverflow
Solution 2 - ReactjsPipView Answer on Stackoverflow
Solution 3 - ReactjsFabio NolascoView Answer on Stackoverflow
Solution 4 - ReactjsChtiwi MalekView Answer on Stackoverflow
Solution 5 - ReactjsTOLULOPE ADETULAView Answer on Stackoverflow
Solution 6 - ReactjsDan AnderssonView Answer on Stackoverflow
Solution 7 - ReactjsMouseAndKeyboardView Answer on Stackoverflow
Solution 8 - ReactjsdealwapView Answer on Stackoverflow
Solution 9 - ReactjsKrupal PatelView Answer on Stackoverflow
Solution 10 - ReactjsMUdit TiWariView Answer on Stackoverflow
Solution 11 - ReactjsmikeymView Answer on Stackoverflow
Solution 12 - ReactjssedView Answer on Stackoverflow
Solution 13 - Reactjskartick shawView Answer on Stackoverflow
Solution 14 - ReactjsarslaanmalikView Answer on Stackoverflow
Solution 15 - ReactjswiggView Answer on Stackoverflow
Solution 16 - ReactjsFerdinView Answer on Stackoverflow
Solution 17 - ReactjsIanNozView Answer on Stackoverflow
Solution 18 - ReactjsVanderley MaiaView Answer on Stackoverflow
Solution 19 - ReactjsAna Gabriele SoaresView Answer on Stackoverflow
Solution 20 - ReactjsBen ThielkerView Answer on Stackoverflow
Solution 21 - ReactjsJeffery ThaGintokiView Answer on Stackoverflow
Solution 22 - ReactjsMuo sigma classesView Answer on Stackoverflow
Solution 23 - ReactjsAmir KatzView Answer on Stackoverflow
Solution 24 - ReactjscoderpcView Answer on Stackoverflow
Solution 25 - ReactjschrisjshermView Answer on Stackoverflow
Solution 26 - ReactjsniksView Answer on Stackoverflow
Solution 27 - Reactjsabdoo_salemView Answer on Stackoverflow
Solution 28 - Reactjsshivam AgrawalView Answer on Stackoverflow
Solution 29 - Reactjsuser8453311View Answer on Stackoverflow
Solution 30 - ReactjsDavid LasryView Answer on Stackoverflow
Solution 31 - ReactjsAditya ShinagariView Answer on Stackoverflow
Solution 32 - ReactjsStephan PsarasView Answer on Stackoverflow
Solution 33 - ReactjsRiyad ZaigirdarView Answer on Stackoverflow
Solution 34 - ReactjsAmer21View Answer on Stackoverflow
Solution 35 - ReactjsAlejandro BarriosView Answer on Stackoverflow