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.

> [email protected] 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

4
  • Try running with admin access to cmd. Commented Jul 1, 2022 at 8:47
  • @Nitika running npm start, npx create-react-app or both? Commented Jul 1, 2022 at 8:48
  • Running both commands as admin didn't help, same error is returned Commented Jul 1, 2022 at 8:54
  • How about any of these solutions? Or here? Commented Jul 1, 2022 at 8:55

2 Answers 2

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.

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

Comments

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

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.