7

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
1

3 Answers 3

12

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
Sign up to request clarification or add additional context in comments.

1 Comment

I was still having same issue even after following this. Mine just got resolved by doing " npm clean-install " command.
0

Best approach

git init

git remote add origin <repo_link>

yarn add gh-pages

yarn build

yarn deploy

Now go to your Github and update the

Settings-->Github Pages-->source (change to gh-pages branch)-->root-->Save

and then check the link/homepage generated.

Comments

0

How to fix this problem

PS

D:\Reactjs\test1> npm install --save gh-pages
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

Added 15 packages, and audited 1496 packages in 7s

232 packages are looking for funding
  run `npm fund` for details

6 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
PS D:\Reactjs\test1> npm run deploy
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] predeploy
> npm run build

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] build
> react-scripts build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  46.61 kB  build\static\js\main.31b5c70f.js
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn git',
  path: 'git',
  spawnargs: [ 'config', 'user.name' ]
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.