Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React app deploy failure on github

Tags:

reactjs

Can Anyone help me out that how can i deploy my react app on github. I have added all required dependecny in my package.json file with using of updated react modules.

Below is my package.json file :

    {
  "name": "git-sample-react",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://ababsheck.github.io/first-react-sample/",
  "dependencies": {
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-scripts": "1.1.4"
  },
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "deploy": "gh-pages -b master -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "gh-pages": "^1.2.0"
  }
}

npm run deploy issue : github

    Failed to get remote.origin.url (task must either be run in a git repository with a configured origin remote or must be configured with the "repo" option).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: `gh-pages -b master -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:\Users\abhis\AppData\Roaming\npm-cache\_logs\2018-08-07T12_21_21_735Z-debug.log
like image 342
Abhishek Bhatore Avatar asked Aug 07 '18 12:08

Abhishek Bhatore


1 Answers

I had the same issue, deploying react app in GitHub and resolved this issues with the following steeps:

  1. Run the command in project folder git remote add origin <url>, with the URL of your repository on GitHub.
  2. Run the command npm install --save-dev gh-pages.
  3. Run the npm run build.
  4. Run the command npm run deploy.
  5. Change the branch in GitHub where you deploy see the image below. Under Source must be gh-pages branch. enter image description here

I also have added the "homepage": "https://ababsheck.github.io/first-react-sample/", before the script like:

"homepage": "https://ababsheck.github.io/first-react-sample/",
"scripts": {
"predeploy": "npm run build",
 ...// the rest of the code
like image 143
Llazar Avatar answered Sep 28 '22 01:09

Llazar