4

I used create-react-app to generate an app.

create-react-app myapp

When I run yarn start or npm start I get this error:

react-scripts start

sh: react-scripts: command not found npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! myapp@0.1.0 start: react-scripts start npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the myapp@0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

When I run npm ls react:

myapp@0.1.0 /Users/johnno/foosball 
└── react@16.2.0

react-scripts is present.

This is my package.json:

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-redux": "^5.0.6",
    "react-router": "^4.2.0",
    "react-scripts": "1.0.17",
    "redux": "^3.7.2",
    "yarn": "^1.3.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

I tried the suggestions from this but to no avail. How can I fix this issue?

tk421
  • 5,775
  • 6
  • 23
  • 34
bier hier
  • 20,970
  • 42
  • 97
  • 166

2 Answers2

8

i solved this by deleting

node_modules
yarn.lock
manifest_lock.json

and installed packages by

npm install

or

yarn
  • 1
    Yes, thank you, this worked for me as well. As a generalization, I expect that all "lock" files should be deleted. (And of course, run ```npm install``` to regenerate node_modules/.) – nydame Mar 24 '18 at 00:55
  • I was trying to fix this in a web based project, 'yarn' works for me. Thank you. – Muzammil Nov 09 '18 at 14:27
0

Following steps worked for me

  1. delete node_modules folder
  2. delete yarn.lock if you are using yarn command or delete package-lock.json if you are using npm command
  3. run yarn install (for yarn command) or npm install (for npm command)
Joydev Pal
  • 303
  • 1
  • 3
  • 13