React website not deploying to GitHub Pages
React website not deploying to GitHub Pages
I've been using node.js/npm to deploy my React website to GitHub Pages but an error keeps showing up and not sure how to approach it. I have been looking around for solutions but there doesn't seem to be anything for this particular scenario:
I run the npm run build
command for the completed application and add the correct GitHub Pages scripts in my package.json file below -
npm run build
"name": "portfolio",
"version": "0.1.0",
"homepage": "https://darstnfrd.github.io/portfolio",
"private": true,
"dependencies":
"bootstrap": "^4.0.0",
"gulp-sass": "^3.1.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.1"
,
"scripts":
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
,
"devDependencies":
"gh-pages": "^1.1.0"
Afterwards, I run npm install --save-dev gh-pages
. From here, when I run npm run deploy
this error below keeps emerging -
npm install --save-dev gh-pages
npm run deploy
> portfolio@0.1.0 deploy C:UsersdarrenDesktopreact2018portfolio
> gh-pages -d build
events.js:183
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
at _errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:686:11)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! portfolio@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the portfolio@0.1.0 deploy 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! C:UsersdarrenAppDataRoamingnpm-cache_logs2018-03-12T02_09_20_837Z-debug.log
My GitHub Pages repository is ready to go. Additional actions I've tried are npm rm -rf node_modules
, npm cache clean
and reinstalling bootstrap dependency.
npm rm -rf node_modules
npm cache clean
What exactly is the error? If any more information is needed, please let me know. Thank you very much!
Which machine are you on? Windows or Mac?
– VivekN
Mar 12 at 3:21
What is
npm add
supposed to do?– Shimon Brandsdorfer
Mar 12 at 3:32
npm add
He probably meant yarn add - - dev
– VivekN
Mar 12 at 3:44
I'm using Windows 10
– Darren Allan
Mar 12 at 3:59
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Why not use zeit or netlify for deployment. It's much easier on those platforms.
– VivekN
Mar 12 at 3:15