2

I have copied a project from a previous machine to my current machine. after running npm install And npm start my terminal gives this error

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

npm ERR! A complete log of this run can be found in: npm ERR! /Users/TimLowe/.npm/_logs/2018-05-04T15_10_08_807Z-debug.log

the code in_logs/2018-05-04T15_10_08_807Z-debug.log is:

0 info it worked if it ends with ok 1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] 2 info using npm@5.6.0 3 info using node@v10.0.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle renew_react@0.1.0~prestart: renew_react@0.1.0 6 info lifecycle renew_react@0.1.0~start: renew_react@0.1.0 7 verbose lifecycle renew_react@0.1.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle renew_react@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin 9 verbose lifecycle renew_react@0.1.0~start: CWD: /Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react 10 silly lifecycle renew_react@0.1.0~start: Args: [ '-c', 'react-scripts start' ] 11 info lifecycle renew_react@0.1.0~start: Failed to exec start script 12 verbose stack Error: renew_react@0.1.0 start:react-scripts start 12 verbose stack spawn ENOENT 12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18) 12 verbose stack at ChildProcess.emit (events.js:182:13) 12 verbose stack at maybeClose (internal/child_process.js:947:16) 12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:236:5) 13 verbose pkgid renew_react@0.1.0 14 verbose cwd /Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react 15 verbose Darwin 15.6.0 16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 17 verbose node v10.0.0 18 verbose npm v5.6.0 19 error file sh 20 error code ELIFECYCLE 21 error errno ENOENT 22 error syscall spawn 23 error renew_react@0.1.0 start:react-scripts start 23 error spawn ENOENT 24 error Failed at the renew_react@0.1.0 start script. 24 error This is probably not a problem with npm. There is likely additional logging output above. 25 verbose exit [ 1, true ] Any ideas on how I can get react to start on my machine?

Wheaties247
  • 21
  • 1
  • 4
  • 1
    Backup your package-lock.json, remove it from the directory, do an `npm install` & `npm start`. If it works it might be something funny with your lock file. – Malcor May 04 '18 at 15:32
  • Did you setup your project using create-react-app (react-scripts comes with it)? Could be fixed with a global update to create-react-app – Sam May 04 '18 at 16:21

2 Answers2

2

I had a somewhat similar experience but in my case it was a project that I'm working on my same machine. I'd turn off PC, come after a few days to continue but when I run npm start I'd get the error you are having.

This is how I resolved it:

  • Navigated to my project directory
  • rm -rf node_modules to delete the node modules folder
  • rm package-lock.json
  • npm cache clean --force
  • npm install
  • npm start

I ran into a similar error again, this time I had already uploaded my project in git, so each time I want to work on it, I'd do a git pull project_url then: - npm install - npm start

A1rPun
  • 16,287
  • 7
  • 57
  • 90
authentichigh
  • 529
  • 5
  • 6
1

You need to manually install the create-react-app package again. It will install all of it's dependencies onto your new machine, including react-scripts.

npm install create-react-app

It should be installed as a global and not part of any specific project.

Chase DeAnda
  • 15,963
  • 3
  • 30
  • 41