1

I tried to deploy my react project on github-pages with npm run deploy and I get the following errors:

events.js:167
     throw er; // Unhandled 'error' event
     ^

Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
    at onErrorNT (internal/child_process.js:407:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! songs@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the songs@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I've already used npm cache clean, deleted node modules and package-lock.json and ran npm install again. I'm new to React and to programming in general so I can not really figure out what the problem is. Also, I should mention that I am a Windows user. Any help would be much appreciated.

Morgana
  • 337
  • 8
  • 19
  • Did you add gh-pages package? – Sreekanth MK Nov 26 '18 at 10:48
  • Yes, I added gh-pages as a devDependency. – Morgana Nov 26 '18 at 10:50
  • Please check whether you have missed anything here https://github.com/gitname/react-gh-pages – Sreekanth MK Nov 26 '18 at 10:53
  • I've done all the steps... – Morgana Nov 26 '18 at 10:56
  • Hi Iro, the error that npm is reporting indicates that node has a problem running git as a child process. Is it possible to provide more info about your setup? I would suggest reviewing https://stackoverflow.com/questions/27688804/how-do-i-debug-error-spawn-enoent-on-node-js and add any more info that you gather to the question or post or these comments. We should be able to get you sorted out. – Rob Kielty Nov 26 '18 at 11:05
  • Hello Rob, thank you, I'll review the link you posted. In the meantime I think I should mention that I use git bash for git commands only, and windows CLI for npm commands. So, Windows CLI does not recognize git commands. – Morgana Nov 26 '18 at 11:13
  • 1
    That makes sense, So if you add the location of the git binary to your PATH environment variable in Windows you will likely fix this problem. – Rob Kielty Nov 27 '18 at 14:31

1 Answers1

0

The solution was to set the environment variable $PATH. I followed the steps mentioned here: How do I debug “Error: spawn ENOENT” on node.js?

Morgana
  • 337
  • 8
  • 19