0

Similar questions that I have tried following

"npm-run-all" is not recognized as an internal or external command

"'react-scripts' is not recognized as an internal or external command"

I am trying to create a React project via the create-react-app cli, but after creating the project I get the error

'react-scripts' is not recognized as an internal or external command, operable program or batch file" 

when I try to launch the dev server via npm start.

What I have tried:

1) Make sure Node and npm are installed and up to date. From the project directory I run (via powershell)

> npm -v
6.7.0
> node -v
v11.11.0

2) Ensure that 'react-scripts' is listed with the correct version number in package.json

"name": "clipd2",
"version": "0.1.0",
"private": true,
"dependencies": {
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-scripts": "^2.1.5"
 },
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }...

3) Delete node_modules folder and package-lock.json and reinstall npm packages

rm -r -fo node_modules
rm package-lock.json
npm install
npm install -S react-scripts

After instalation the react-scripts directory is found (and populated) in node_modules

4) Make sure npm is in the environment PATH variable

> echo $Env:Path
....C:\Users\notMyUsername\AppData\Roaming\npm

I am at a loss for next steps. Strangely enough, I have another React app housed in the same parent directory

clipdReact
    clipd
    clipd2

And there are no problems when using npm start in the clipd project (whereas the failing project is clipd2)

Any suggestions or tips would be greatly appreciated!

**UPDATE

This bug was filed but is still open react-scripts is not recognized

You can start the dev server (from your project's directory) with

.\node_modules\.bin\react-scripts start

Be careful generating the production build with a command similar to the one above - I had problems with babel and polyfills when trying to do so.

ihunter2839
  • 77
  • 1
  • 2
  • 14
  • Possibly a duplicate of https://stackoverflow.com/questions/54525742/npm-run-all-is-not-recognized-as-an-internal-or-external-command/54526796#54526796 ? – Matt Holland Mar 06 '19 at 23:46
  • Possible duplicate of ["npm-run-all" Is Not Recognized As an Internal or External Command](https://stackoverflow.com/questions/54525742/npm-run-all-is-not-recognized-as-an-internal-or-external-command) – Matt Holland Mar 06 '19 at 23:46
  • @MattHolland I don't want to install react-scripts globally as it is explicitly stated here [link](https://github.com/facebook/create-react-app/issues/2436#issuecomment-306830791) that it is a poor solution. npm start is already a defined script, so I do not believe I should need to redefine it. Also, the path to npm is in my PATH variable, as per the second answer in that question. Unless there is something that I missed here I do not believe it to be a duplicate. – ihunter2839 Mar 06 '19 at 23:58
  • @ihunter2839 did you ever resolve this? – Daniel Kotin Jul 14 '19 at 20:41
  • @DanielKotin I filed this bug report [react-scripts is not recognized](https://github.com/facebook/create-react-app/issues/6603) I start the dev server from the project folder with `.\node_modules\.bin\react-scripts start` I tried to run a similar command to the one above to generate the production build and experience spurious errors with babel/transpliers and have resorted to building on a linux machine. Good luck. – ihunter2839 Jul 14 '19 at 21:07

2 Answers2

1

What worked for me in the end, was setting the script shell to powershell. The command for that is npm config set script-shell powershell and npm config delete script-shell to reset the config. I'm not sure why that worked, my guess is that since there are always 3 script files in node_modules\.bin that somehow the wrong shell was used for the wrong script or something like that.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0
npm install react-scripts --save --force
Fedor
  • 17,146
  • 13
  • 40
  • 131