12

I follow a udemy course, using create-react-app, then starting the localhost with npm start. It works fine until i install the react-router-dom then i get this error in the terminal :

react-scripts' is not recognized as an internal or external command, operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! venue@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the venue@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Could Someone explain what is going on? And what to do to fix it ?

Thank you

Bedla
  • 4,789
  • 2
  • 13
  • 27
wijnieMen
  • 121
  • 1
  • 1
  • 6
  • Possible duplicate: https://stackoverflow.com/questions/47928735/react-scripts-is-not-recognized-as-an-internal-or-external-command – Ariel Salem Oct 15 '18 at 19:43

7 Answers7

20

There is some issue in npm install which is not able to complete the installation of react scripts. Follow these simple steps to get it worked.

  1. Remove node_modules foldert
  2. Remove package-lock.json file
  3. Run npm install
  4. Run npm i -S react-scripts
  5. Run npm start

It should work now.

4

What I've noticed is that if you switch frequently version of packages, this issue pops up. Mostly its a cache issue. and would be resolved by performing following steps:

  1. Remove the node_modules directory so that we get a fresh copy of packages
  2. Remove the package-lock.json or yarn.lock
  3. Now clear the cache, we need to run the npm cache clean --force command in terminal. PS: clean --> deletes the all data from local cache folder
  4. Run npm i or yarn
  5. Now if you run your script, it should work.
just-be-weird
  • 1,242
  • 9
  • 7
2

Run "npm install -g react-scripts". This is outside the folder you are trying to run. This will cause the command to be recognized internally.

  • 3
    "npm install react-scripts -g " "-g" anywhere is not recommended. it installs the script globally and affects other repo's project as well. stay away from it. i wasted a day troubleshooting that issue. – Shahab Khan Jan 15 '21 at 12:16
  • As pointed out in above comment we should not install packages like react-scripts, react etch which will be specific to each project. – just-be-weird Oct 20 '21 at 10:36
1

Sometime scripts are installed but prevented from running because of OS security policies.

If you are working in a new setup, run Powershell as Administrator and run this command and try running your script afterwards

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Noble Kuz
  • 211
  • 2
  • 4
0

It is showing an error about react-scripts is not available in your node-modules folder.

Check your package.json file if you find "react-scripts": "3.4.1". You can hit the command:


npm install react-scripts --save

Or you can add "react-scripts": "3.4.1" manually.

Awais Ali
  • 1
  • 2
0

To rectify this issue follow the following steps

  1. run npm install

  2. then run npm start

    ( OR )

  3. npm install --legacy-peer-deps

  4. npm start

This command worked fine for me

The above command is forced to download the node modules in your system, which will used to start the server.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Vikram Parimi Sep 07 '22 at 12:11
0

rectified solution:-

Remove node modules folder Remove package-lock.json and yarn.lock file Run npm install Run npm i -g react-scripts Run npm start

p.s: remember there must be -g in 4th step