反应网站未部署到GitHub页面

时间:2018-03-12 03:07:22

标签: javascript node.js reactjs npm github-pages

我一直在使用 node.js / npm 将我的 React 网站部署到 GitHub页面,但错误一直显示而不是确定如何接近它。我一直在寻找解决方案,但似乎没有针对这种特殊情况的任何事情:

我为已完成的应用程序运行npm run build命令,并在我的package.json文件中添加正确的GitHub Pages脚本 -

{
  "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"
  }
}

之后,我运行npm install --save-dev gh-pages。从这里,当我运行npm run deploy时,下面的错误不断出现 -

> portfolio@0.1.0 deploy C:\Users\darren\Desktop\react2018\portfolio
> 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:\Users\darren\AppData\Roaming\npm-cache\_logs\2018-03-12T02_09_20_837Z-debug.log

我的GitHub Pages存储库已准备就绪。我尝试过的其他操作是npm rm -rf node_modulesnpm cache clean并重新安装引导依赖项。

究竟是什么错误?如果需要更多信息,请告诉我。非常感谢你!

0 个答案:

没有答案