react-scripts command not found
Describe the bug
None of the react dependencies are being installed.
npm ls react
└── [email protected]
So I am getting 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! [email protected] start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] start script.
Did you try recovering your dependencies?
I have deleted my project and run npx create-react-app my-app several times.
I have deleted my node_modules and reinstalled dependencies.
I have updated npm to latest version.
I have deleted node and reinstalled.
None of these things have worked.
Environment
Environment Info:
System: OS: macOS High Sierra 10.13.6 CPU: (4) x64 Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz Binaries: Node: 10.16.0 - /usr/local/bin/node Yarn: Not Found npm: 6.10.0 - /usr/local/bin/npm Browsers: Chrome: 75.0.3770.100 Firefox: 67.0.4 Safari: 12.1.1 npmPackages: react: ^16.8.6 => 16.8.6 react-dom: ^16.8.6 => 16.8.6 react-scripts: 3.0.1 => 3.0.1 npmGlobalPackages: create-react-app: 3.0.1
Steps to reproduce
(Write your steps here:)
- npx create-react-app my-app
- cd my-app
- npm start
Full error log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/work/Documents/Summer_2019_Study/Node/odin-node/Project2:MiniMessageBoard/frontend/my-app/node_modules/.bin:/usr/local/mysql/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Postgres.app/Contents/Versions/latest/bin
9 verbose lifecycle [email protected]~start: CWD: /Users/work/Documents/Summer_2019_Study/Node/odin-node/Project2:MiniMessageBoard/frontend/my-app
10 silly lifecycle [email protected]~start: Args: [ '-c', 'react-scripts start' ]
11 info lifecycle [email protected]~start: Failed to exec start script
12 verbose stack Error: [email protected] 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:198:13)
12 verbose stack at maybeClose (internal/child_process.js:982:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
13 verbose pkgid [email protected]
14 verbose cwd /Users/work/Documents/Summer_2019_Study/Node/odin-node/Project2:MiniMessageBoard/frontend/my-app
15 verbose Darwin 17.7.0
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
17 verbose node v10.16.0
18 verbose npm v6.10.0
19 error file sh
20 error code ELIFECYCLE
21 error errno ENOENT
22 error syscall spawn
23 error [email protected] start: `react-scripts start`
23 error spawn ENOENT
24 error Failed at the [email protected] start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
Using the command npx react-scripts start allows it to run, but this still does not fix my bug.
I have the exact same issue aside from environment. Even the npx react-scripts start workaround works for me (although not extremely practical as mentioned 😀). The problem for me is occurring on my Windows 10 1903 desktop. Oddly enough, npm start is working fine for me on my 1903 Surface Pro 6. Here's my environment info -
Desktop Environment Info (not working):
System: OS: Windows 10 CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz Binaries: Node: 10.16.0 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 44.18362.1.0 Internet Explorer: 11.0.18362.1 npmPackages: react: ^16.8.6 => 16.8.6 react-dom: ^16.8.6 => 16.8.6 react-scripts: 3.0.1 => 3.0.1 npmGlobalPackages: create-react-app: Not Found
Surface Pro 6 Environment Info (working):
System: OS: Windows 10 CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz Binaries: Node: 10.16.0 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 44.18362.1.0 Internet Explorer: 11.0.18362.1 npmPackages: react: ^16.8.6 => 16.8.6 react-dom: ^16.8.6 => 16.8.6 react-scripts: 3.0.1 => 3.0.1 npmGlobalPackages: create-react-app: Not Found
My verbose error logs:
> 0 info it worked if it ends with ok
> 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
> 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
> 1 verbose cli 'start' ]
> 2 info using [email protected]
> 3 info using [email protected]
> 4 verbose run-script [ 'prestart', 'start', 'poststart' ]
> 5 info lifecycle [email protected]~prestart: [email protected]
> 6 info lifecycle [email protected]~start: [email protected]
> 7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
> 8 verbose lifecycle [email protected]~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\burka\Dev\testtwo\node_modules\.bin;C:\Users\burka\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\burka\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\NVIDIA Corporation\NVIDIA NGX;C:\Windows\System32;C:\Program Files\nodejs;C:\Users\burka\AppData\Local\Microsoft\WindowsApps;C:\Users\burka\AppData\Local\hyper\app-2.1.2\resources\bin;C:\Users\burka\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\burka\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
> 9 verbose lifecycle [email protected]~start: CWD: C:\Users\burka\Dev\testtwo
> 10 silly lifecycle [email protected]~start: Args: [ '/d /s /c', 'react-scripts start' ]
> 11 silly lifecycle [email protected]~start: Returned: code: 1 signal: null
> 12 info lifecycle [email protected]~start: Failed to exec start script
> 13 verbose stack Error: [email protected] start: `react-scripts start`
> 13 verbose stack Exit status 1
> 13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
> 13 verbose stack at EventEmitter.emit (events.js:198:13)
> 13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
> 13 verbose stack at ChildProcess.emit (events.js:198:13)
> 13 verbose stack at maybeClose (internal/child_process.js:982:16)
> 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
> 14 verbose pkgid [email protected]
> 15 verbose cwd C:\Users\burka\Dev\testtwo
> 16 verbose Windows_NT 10.0.18362
> 17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
> 18 verbose node v10.16.0
> 19 verbose npm v6.9.0
> 20 error code ELIFECYCLE
> 21 error errno 1
> 22 error [email protected] start: `react-scripts start`
> 22 error Exit status 1
> 23 error Failed at the [email protected] start script.
> 23 error This is probably not a problem with npm. There is likely additional logging output above.
> 24 verbose exit [ 1, true ]
>
Stumbled accross this comment and I can also run .\node_modules\.bin\react-scripts.cmd start in PowerShell to start the app. I know this isn't an option for OP on a Mac, but maybe it'll help debug?
I solved my issue. I had improper syntax for my parent folder. I named it "Project2:somethingsomething". The colon in the name was turned into a "/" by the operating system for some reason, thus the folder path was completely broken. Could you try running your project in a different parent folder and seeing if that works?