tschaub / gh-pages

General purpose task for publishing files to a gh-pages branch on GitHub
https://www.npmjs.com/package/gh-pages
MIT License
3.25k stars 191 forks source link

gh-pages -d build events.js:174. throw er; // Unhandled 'error' event #363

Open ahmedgulabkhan opened 4 years ago

ahmedgulabkhan commented 4 years ago

Installed gh-pages as dev dependency in my react project. The below error is displayed everytime I run the command npm run deploy to deploy the app to github using gh-pages.

Error:

sample-react-deploy@0.1.0 deploy C:\Users\Ahmed Khan\Development Projects\Reactjs Projects\sample-react-deploy
> gh-pages -d build

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

Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sample-react-deploy@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sample-react-deploy@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:\Users\Ahmed Khan\AppData\Roaming\npm-cache\_logs\2020-06-30T11_24_22_821Z-debug.log

My package.json file:

{
  "homepage": "https://ahmedgulabkhan.github.io/sample-react-deploy",
  "name": "sample-react-deploy",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "^3.4.1"
  },
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "gh-pages": "^3.1.0"
  }
}

Searched for some help online, and downgraded react-scripts to version 2.1.8. But the issue is still not resolved.

Reboog711 commented 4 years ago

Having the same error, trying to run this in Jenkins.. I'm trying to publish the results of a CompDoc generation for an Angular library.

[] Running shell script

++ pwd

+ docker run --rm -v /tmp/swarm/cdf01b8d2d22/workspace/[redacted]/build -v /var/run/docker.sock:/var/run/docker.sock 950377457506.dkr.ecr.us-east-1.amazonaws.com/xce/docker-build-npm:latest-v10-chromium run publish-docs

> [redacted]@0.0.0 publish-docs /build

> gh-pages -d docs

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

Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [repo name redacted]@0.0.0 publish-docs: `gh-pages -d docs`

npm ERR! Exit status 1

npm ERR! 

npm ERR! Failed at the dss-ui-shared-components-sample@0.0.0 publish-docs 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!     /root/.npm/_logs/2020-07-01T18_57_32_018Z-debug.log

script returned exit code 1

The package.json:

{
  "name": "[redacted]",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "gh-pages": "gh-pages",
    "compdoc": "compodoc -p projects/[redacted]/tsconfig.lib.json --output=docs",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "generate-docs": "npm run compdoc",
    "publish-docs": "gh-pages -d docs -"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^9.1.4",
    "@angular/cdk": "^9.1.4",
    "@angular/common": "^9.1.4",
    "@angular/compiler": "^9.1.4",
    "@angular/core": "^9.1.4",
    "@angular/forms": "^9.1.4",
    "@angular/material": "^9.2.2",
    "@angular/platform-browser": "^9.1.4",
    "@angular/platform-browser-dynamic": "^9.1.4",
    "@angular/router": "^9.1.4",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.4",
    "@angular-devkit/build-ng-packagr": "~0.901.4",
    "@angular/cli": "~9.1.4",
    "@angular/compiler-cli": "^9.1.4",
    "@angular/language-service": "^9.1.4",
    "@compodoc/compodoc": "^1.1.9",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "gh-pages": "^3.1.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "ng-packagr": "^9.0.0",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "tslint-eslint-rules": "~5.4.0",
    "typescript": "~3.8.3"
  }
}

Everything works if I run from my local.

Our Jenkins scripts are set up to run npm inside a docker image, I believe. It successfully checks out the repo, so it has access, but was thinking that gh-pages could not find the git info.

adamsza commented 4 years ago

I added "C:\Program Files\Git\bin\git.exe" and "C:\Program Files\Git\cmd" to my system variables and it fixed the problem for me.

SystemDZ commented 4 years ago

INSTALL/REINSTALL GIT Update NPM Reopen EDITOR

this solved my problem

ahmedgulabkhan commented 4 years ago

@SystemDZ I followed these steps even before raising the issue, it didn't solve the problem

SystemDZ commented 4 years ago

@ahmedgulabkhan try start from all over again following a video on youtube that shows you step by step, you must be making a mistake some where in the process.

ckot commented 3 years ago

probably pulling at straws here, but regarding this working on localhost and not on jenkins, do you know if the same version of node is running in both environments, or if using nvm, potentially you have the proper version of node installed and its merely not configured to be using the proper version??? I haven't had issues with this, but quite recently had an issue with a different node package not working in a different environment, and the node version was indeed the issue