0

I'm having some trouble with react-scripts after creating a new react project. I created/initialised the project using npx create-react-app dashboard. After going inside the dashboard folder and running npm start (without doing anything else beforehand), I get the following error:

>npm start
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> dashboard@0.1.0 start
> react-scripts start

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

I have checked the package.json file and it does have react-scripts listed (v5.0.1, full package.json below) and checking the node_modules folder shows a react-scripts folder there and react-scripts files (cmd, ps1 and 1 with no extension) inside the .bin folder too.

I've tried clearing the npm cache (npm cache clean -f), installing things again (deleting package-lock.json and node_modules folder then running npm install) and nothing seems to change.

I've also tried running npm start in command prompt, powershell and powershell as an admin. I've also tried restarting my PC and retrying too without any luck.

Specs:
Edition: Windows 10 Pro
Version: 21H2
OS build: 19044.1766
Experience  Windows Feature Experience Pack: 120.2212.4180.0
Node JS version: 16.15.1
npm version: 8.11.0

full package.json:

{
  "name": "dashboard",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

If anyone has any ideas on how to fix this, I'd appreciate the help. Let me know if you need/want any more info that might help debug this issue

user2371266
  • 163
  • 8
  • Try running with admin access to cmd. – Nitika Jul 01 '22 at 08:47
  • @Nitika running `npm start`, `npx create-react-app` or both? – user2371266 Jul 01 '22 at 08:48
  • Running both commands as admin didn't help, same error is returned – user2371266 Jul 01 '22 at 08:54
  • How about [any of these solutions](https://stackoverflow.com/questions/47928735/react-scripts-is-not-recognized-as-an-internal-or-external-command)? [Or here?](https://exerror.com/react-scripts-is-not-recognized-as-an-internal-or-external-command/) – Andy Jul 01 '22 at 08:55

2 Answers2

0

As suggested in this comment: https://stackoverflow.com/a/68394617/2371266, running npm config set script-shell powershell seems to have worked. I tried deleting the script-shell config afterwards and retrying and got the original error again so I'm assuming it is defaulting to something else and that's making things freak out a bit. I guess I'll just keep it pointed at powershell for now.

user2371266
  • 163
  • 8
0

I experienced the same problem as you, and this helped me solve it, just try installing

react-scripts

on your project:

npm install react-scripts

just like that you are good to go!!!!

Moritz Ringler
  • 9,772
  • 9
  • 21
  • 34