Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Deploy to GitHub Pages

Deploy to gh-pages fails

As far as I can tell I followed the video to the nth degree. When I enter npm run build I get:

> reactrouter@0.1.0 build /Users/doug5solas/training/treehouse/courses/fsjsCourses/React/reactrouter
> react-scripts build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  51.72 KB  build/static/js/2.cbd55d0d.chunk.js
  5.15 KB   build/static/js/main.28ae21fa.chunk.js
  1.06 KB   build/static/css/main.93054ec2.chunk.css
  772 B     build/static/js/runtime~main.55800f53.js

The project was built assuming it is hosted at /ReactRouter/.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
To publish it at https://dhawkinson.github.io/ReactRouter, run:

  npm run deploy

Find out more about deployment here:

  http://bit.ly/CRA-deploy

When I enter npm run deploy, I get:

> reactrouter@0.1.0 deploy /Users/doug5solas/training/treehouse/courses/fsjsCourses/React/reactrouter
> gh-pages -d build

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! reactrouter@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the reactrouter@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!     /Users/doug5solas/.npm/_logs/2019-02-14T00_52_36_331Z-debug.log

Here is my debug log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using npm@6.7.0
3 info using node@v10.13.0
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle reactrouter@0.1.0~predeploy: reactrouter@0.1.0
6 verbose lifecycle reactrouter@0.1.0~predeploy: unsafe-perm in lifecycle true
7 verbose lifecycle reactrouter@0.1.0~predeploy: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/doug5solas/training/treehouse/courses/fsjsCourses/React/reactrouter/node_modules/.bin:/usr/local/mysql/bin:/usr/local/mongodb/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
8 verbose lifecycle reactrouter@0.1.0~predeploy: CWD: /Users/doug5solas/training/treehouse/courses/fsjsCourses/React/reactrouter
9 silly lifecycle reactrouter@0.1.0~predeploy: Args: [ '-c', 'npm run build' ]
10 silly lifecycle reactrouter@0.1.0~predeploy: Returned: code: 0  signal: null
11 info lifecycle reactrouter@0.1.0~deploy: reactrouter@0.1.0
12 verbose lifecycle reactrouter@0.1.0~deploy: unsafe-perm in lifecycle true
13 verbose lifecycle reactrouter@0.1.0~deploy: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/doug5solas/training/treehouse/courses/fsjsCourses/React/reactrouter/node_modules/.bin:/usr/local/mysql/bin:/usr/local/mongodb/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
14 verbose lifecycle reactrouter@0.1.0~deploy: CWD: /Users/doug5solas/training/treehouse/courses/fsjsCourses/React/reactrouter
15 silly lifecycle reactrouter@0.1.0~deploy: Args: [ '-c', 'gh-pages -d build' ]
16 silly lifecycle reactrouter@0.1.0~deploy: Returned: code: 1  signal: null
17 info lifecycle reactrouter@0.1.0~deploy: Failed to exec deploy script
18 verbose stack Error: reactrouter@0.1.0 deploy: `gh-pages -d build`
18 verbose stack Exit status 1
18 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
18 verbose stack     at EventEmitter.emit (events.js:182:13)
18 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
18 verbose stack     at ChildProcess.emit (events.js:182:13)
18 verbose stack     at maybeClose (internal/child_process.js:962:16)
18 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
19 verbose pkgid reactrouter@0.1.0
20 verbose cwd /Users/doug5solas/training/treehouse/courses/fsjsCourses/React/reactrouter
21 verbose Darwin 18.2.0
22 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
23 verbose node v10.13.0
24 verbose npm  v6.7.0
25 error code ELIFECYCLE
26 error errno 1
27 error reactrouter@0.1.0 deploy: `gh-pages -d build`
27 error Exit status 1
28 error Failed at the reactrouter@0.1.0 deploy script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 1, true ]

here is my package-json

{
    "name": "reactrouter",
    "version": "0.1.0",
    "private": true,
    "homepage": "https://dhawkinson.github.io/ReactRouter",
    "devDependencies": {
        "react-scripts": "^2.1.5"
    },
    "dependencies": {
        "gh-pages": "^2.0.1",
        "react": "^15.5.4",
        "react-dom": "^15.5.4",
        "react-router-dom": "^4.3.1",
        "typescript": "^3.3.3"
    },
    "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"
    },
    "browserslist": [
        ">0.2%",
        "not dead",
        "not ie <= 11",
        "not op_mini all"
    ]
}

3 Answers

Hello Doug. Did you create a GitHub repository for this work and connect it with your local git repository?

Yes I did.

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 27,696 Points

Is your remote origin set up correctly? This leads me to believe it's not:

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).

Try doing this:

$ git remote remove origin
$ git remote add origin https://github.com/dhawkinson/ReactRouter.git
$ git push -u origin master

Source: https://github.com/facebook/create-react-app/issues/3216#issuecomment-333133079

Mohammed Fellak
Mohammed Fellak
30 Points

INSTALL/REINSTALL GIT Update NPM Reopen EDITOR

this solved my problem