46

I am learning to react. The version I installed is 16. I installed prop-types via npm after I got an error that 'react-scripts' is not recognized as an internal or external command, operable program or batch file."

enter image description here

mansour lotfi
  • 524
  • 2
  • 7
  • 22
David Essien
  • 1,463
  • 4
  • 22
  • 36
  • Are you using `create-react-app`? – Agney Feb 23 '18 at 06:57
  • run npm install if you are using create-react-app – Shubham Khatri Feb 23 '18 at 07:02
  • yes, i am using create-react-app, but it has been working till i installed prop-types – David Essien Feb 23 '18 at 07:04
  • make it available globally. npm install -g create-react-app – Javed Shaikh Feb 23 '18 at 07:07
  • that's exactly what I did and I have run npm install and it is still not working. Same error. The whole stuff was working till in installed prop-types. I have tried to uninstall it, still getting errors. – David Essien Feb 23 '18 at 07:12
  • 3
    do one thing delete node_modules and package-lock.json file. and again npm install – Javed Shaikh Feb 23 '18 at 07:18
  • Possible duplicate of ['react-scripts' is not recognized as an internal or external command](https://stackoverflow.com/questions/47928735/react-scripts-is-not-recognized-as-an-internal-or-external-command) – cham Feb 12 '19 at 23:03
  • I'm going through a similar issue while trying to run this through my PyCharm terminal (Windows 10). I'm able to get react-scripts to run if I instead use PowerShell. – TheGRS May 26 '19 at 18:49
  • I Faced same issue , react-scripts is not recognized as an internal or external command, USE THIS COMMAND: npm i -g react-scripts – suresh narasimman Aug 06 '20 at 06:44

19 Answers19

70

It is an error about react-scripts file missing in your node modules directory at the time of installation.

Now, you can add manually this via the command:

npm install react-scripts

Yogesh Borad
  • 4,287
  • 1
  • 18
  • 17
16

I had the same issue, resolved by simply running following command in the project root folder -

npm install react-scripts --save
Sachin Vairagi
  • 4,894
  • 4
  • 35
  • 61
  • Installing react-scripts globally is not recommended by the CRA maintainers: https://github.com/facebook/create-react-app/issues/2436#issuecomment-306830791 – Tomáš Hübelbauer May 28 '19 at 07:51
  • @TomášHübelbauer - should it be --save – Sachin Vairagi May 28 '19 at 12:25
  • 1
    You have `react-scripts` `--save`d by default after you have used CRA. So you do not need to re-save it. If `npm install` (with or without deleting `node_modules`) doesn't fix the issue, the problem is likely with an old version of NPM or a problem with PATH which can be fixed as per my answer. – Tomáš Hübelbauer May 28 '19 at 13:02
9

If it doesn't get resolved even after running

npm install 

OR

npm install react-scripts 

Run:

node node_modules/react-scripts/scripts/start.js

Or use node js command-line tool and do npm install and npm start This solved the problem for me

8

If none of the above solutions works and you have already installed the "react-scripts" package using

npm install react-scripts --save

You can try the below solution to run the application.

You should see the following in your package.json file

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
}

The script : "start": "react-scripts start" is linked to the file : nodemon node_modules/react-scripts/scripts/start.js which is used to start the project in the development env

Try to start the project directly using the below commands:

node node_modules/react-scripts/scripts/start.js

or if you have nodemon installed then try

nodemon node_modules/react-scripts/scripts/start.js

Hope this helps :)

Harry Karwal
  • 81
  • 1
  • 3
5

Simply remove node_modules folder and run npm install

Saurav
  • 392
  • 4
  • 4
  • it has broken everything! C:\Users\Xxxx>npm install internal/modules/cjs/loader.js:582 throw err; ^ Error: Cannot find module 'semver' – Giox Nov 29 '18 at 17:42
  • by running npm install it will generate node_module package with all other dependencies into it. Goto to project path- run npm install from CLI – Saurav Nov 30 '18 at 07:53
5

I found the community answer, which is perfect solution enter image description here

Asmi
  • 651
  • 1
  • 8
  • 16
2

I just had this issue and this solution worked just fine.

run:

npm install react-scripts

that should solve it... Enjoy!!!

1

Just type npm install and after that run npm start. This solved the problem for me.

Farasat Ali
  • 398
  • 3
  • 6
0

One of the causes of this issue is corrupted PATH and the only fix I found for that issue was to (re)install NVM and let the installer take control over the installed Node version when it asks to do so and it will fix the PATH for you. In my case that was the fix.

Tomáš Hübelbauer
  • 9,179
  • 14
  • 63
  • 125
0

deleting the node_modules folder and the *.lock file then running npm install in the project directory through the terminal worked. I tried with yarn install and it worked too after removing the mentioned files above.

Hassan A
  • 49
  • 3
0

It's quite common problem. Do the following steps:-

  • npm audit The message will be like - 7 vulnerabilities (1 low, 6 high) You will get the vulnerabilities, and now fix it with
  • npm audit fix or npm audit fix --force will prompt message like this removed 4 packages, changed 82 packages, and audited 1623 packages in 7s

found 0 vulnerabilities

Problem Solved, Happy Hacking

Shankar Ganesh Jayaraman
  • 1,401
  • 1
  • 16
  • 22
0

Resolved by running the following command:

yarn add react-scripts

jdaniel
  • 1
  • 1
0

For this error you just have to delete lock file and use command yarn

Vijay Gaikwad
  • 161
  • 1
  • 3
0

You just have to install React Script Again. You just need to run the command npm i react-scripts and then run npm start

Dev Asit
  • 113
  • 1
  • 5
0

this error has happened to me in mern stack, and took around 3h to fix it: in the end, this issue because the current node version is not the same I was used to creating the project for the first time. I hope this proposition helped someone in the future.

-1

Hello I'm learning the MERN stack as well(wise use of quarantine time right? ) Anyways, I'm using WINDOWS 10, and I have the same error as well.

I tried react-scripts start and react-scripts is not recognized as an internal command

I did a bit of googling and found out that you need to npm install react-scripts -g <- notice the -g (stands for global? I think? )

I hope this helps :>

Skrmnghrd
  • 558
  • 4
  • 10
-1

Just go to the Terminal and on the directory which you start your server. TYPE npm install react-scripts

you will be good to go

ephantus okumu
  • 178
  • 2
  • 11
-1

I was trying to use 'nodemon server' then had the same error. When I tried 'npx nodemon server', it worked. Try to use 'npx' in front of 'npm'

-2

Instead of writing react-scripts start just write npm start.