392

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.

4
  • You created your app with create-react-app app and cded into it with cd app before running npm start? Commented Nov 11, 2016 at 11:08
  • it created it with create-react-app app Commented Nov 11, 2016 at 11:09
  • 42
    Try npm install before running npm start? Commented Nov 11, 2016 at 11:10
  • I was accidentally using react-scripts-ts instead of react-scripts. Commented Jul 29, 2021 at 12:57

49 Answers 49

711

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).

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

8 Comments

This solution worked for me. But I also had to remove package-lock.json.
I also want to mention this happens if the project is initialized using Yarn but then you attempt to run npm install. This won't work: they're not compatible with each other. Running npm install on top of a Yarn-produced tree will corrupt it. I filed an issue here but for now the solution is (if you use Yarn) to always use yarn add to add a package, and to delete node_modules and re-run yarn if you mess it up.
yes, it worked. But it seems like a common issue across the users. I would like to know what exactly causing the issue over here.
@ArunRamachandran the package.json file should not be overwritten when adding new deps with npm install newDep. Perhaps your project is using yarn? See stackoverflow.com/a/49575980/2700718
It didn't work for me, I even tried deleting package-lock.json file
|
86

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

3 Comments

This has fixed my issue. I had to run: yarn add react-scripts
didn't work for me
It worked for me. thanks!
42

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!

2 Comments

Does anyone know WHY using yarn fixes an npm problem?
In my case, yarn start was not working as the dedicated port (8081) was reserved by previously running process. I had to kill it kill -9 $(lsof -t -i:8081 -sTCP:LISTEN) and run yarn start
28

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.

3 Comments

react-scripts is not found in $PATH, any clue on how to add node scripts there?
Are you sure You've installed React either globally or to that project?
This response solved the issue for me, but right now, every single project need this to be able to start. How to fix this?
25

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

2 Comments

No luck for me, I even tried deleting package-lock.json
This three step thingie did it for me, nothing else worked!
18

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.

5 Comments

wow, I tried everything said above but none worked, I didn't use space but had '&' in parent folder containing react app(not even in app's name).This is tricky thing, such small things can give so much issue
I've had the same problem, because a '&" in my path I lost the last 50 minutes trying to solve the problem :/
i had my app nested in a folder project:latest.. i think ':' was the culprit
I removed "spaces" and "/" from my path folder's names and it worked !!
Aaagh. I had a "/" in one of my folder names. This is apparently a bad idea. Changed that to a "-" and everything worked. Thanks
16

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.

Comments

11

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

Comments

7

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 ^-^

Comments

7

Run npm i before you start the react project

Comments

6

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

Comments

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

Above command worked for me.

Comments

4

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.

Comments

3

Just ran into this problem after installing material-ui.

Solved it by simply running npm install again.

Comments

3

Just doing an Yarn install solved the problem for me

Comments

3

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 .

1 Comment

This seems rather vague. The PATH is not particularly sensitive to what characters your directory names contain, other than of course if a directory contains a literal : which is the PATH delimiter (but on a Mac, you can't really have colons in file names anyway IIRC). Naturally, you need to make sure that you have not misspelled the directories in your PATH (including but not limited to ensuring that your shell's strartup files don't contain DOS carriage returns, which could happen if you edit them on Windows; see also stackoverflow.com/questions/39527571)
3

delete node_modules

  1. run npm install
  2. after that run npm start

if above does't work

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

if above solutions does not fixed your problem, try the following this worked for me:

  1. if you want to start on another port or PORT command not found error then do the following steps:
    1. open package.json file
    2. inside script replace the start command with below "start": "set PORT=3006 && react-scripts start"
    3. To change the port of your app, you can also create a new file name .env in the root directory of the project and write in it PORT=3006 (then save the file). Now run your app using npm start.

Comments

3

My package.json has react-scripts with a version of ^0.0.0

So I updated package.json and changed it to ^4.0.3 and ran npm install

All of a sudden a lot more stuff happened.

Note: When I ran an npm audit fix it wanted to set react-scripts back to ^0.0.0 again.

1 Comment

Happened to me as well!
2

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

Comments

2

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

Comments

2

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

Comments

2

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.

Comments

2

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

Comments

2

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

Comments

2

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!

Comments

2

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 !!!

1 Comment

only reinstalling worked for me, didn't need to clean cache
2

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.

Comments

2

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"

Comments

2

I tried removing node_modules and re-installing the dependencies but at the end this command helped me npm i react-scripts

Comments

1

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.

Comments

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.