盖茨比部署到Github失败

时间:2018-05-30 17:45:35

标签: reactjs deployment github-pages gatsby

挣扎着这个。我已经在本地下载并安装了这个Gatsby初学者包:

https://github.com/ChangoMan/gatsby-starter-dimension

我正在尝试部署到我的github网页: https://reenaverma.github.io/

我已按照说明进行操作,但在运行npm run deploy时出现此错误:

> gatsby-starter-dimension@1.0.0 deploy /Users/reenaverma/development/gatsby-starter-dimension
> gatsby build && gh-pages -b master -d public

success delete html and css files from previous builds — 0.014 s
success open and validate gatsby-config — 0.004 s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
success copy gatsby files — 0.014 s
success onPreBootstrap — 0.858 s
success source and transform nodes — 0.111 s
success building schema — 0.239 s
success createLayouts — 0.006 s
success createPages — 0.019 s
success createPagesStatefully — 0.005 s
success onPreExtractQueries — 0.004 s
success update schema — 0.102 s
success extract queries from components — 0.070 s
success run graphql queries — 0.098 s
success write out page data — 0.004 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s

info bootstrap finished - 4.183 s

success Building CSS — 2.647 s
success Building production JavaScript bundles — 4.936 s
success Building static HTML for pages — 1.787 s
info Done building in 13.557 sec
sh: gh-pages: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! gatsby-starter-dimension@1.0.0 deploy: `gatsby build && gh-pages -b master -d public`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the gatsby-starter-dimension@1.0.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/reenaverma/.npm/_logs/2018-05-30T17_41_52_319Z-debug.log

这是我的package.json:

{
  "name": "gatsby-starter-dimension",
  "description": "Gatsby Starter - Dimension by HTML5 UP",
  "version": "1.0.0",
  "author": "Hunter Chang",
  "dependencies": {
    "gatsby": "^1.9.235",
    "gatsby-link": "^1.6.39",
    "gatsby-image": "^1.0.42",
    "gatsby-plugin-google-analytics": "^1.0.24",
    "gatsby-plugin-react-helmet": "^1.0.8",
    "gatsby-plugin-sass": "^1.0.23",
    "gatsby-plugin-sharp": "^1.6.41",
    "gatsby-remark-copy-linked-files": "^1.5.30",
    "gatsby-remark-images": "^1.5.56",
    "gatsby-source-filesystem": "^1.5.27",
    "gatsby-transformer-remark": "^1.7.37",
    "gatsby-transformer-sharp": "^1.6.22",
    "lodash": "^4.17.4"
  },
  "homepage": "https://github.com/ChangoMan/gatsby-starter-dimension",
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "main": "n/a",
  "repository": {
    "type": "git",
    "url": "https://github.com/ChangoMan/gatsby-starter-dimension.git"
  },
  "scripts": {
    "dev": "gatsby develop",
    "lint": "./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .",
    "test": "echo \"Error: no test specified\" && exit 1",
    "develop": "gatsby develop",
    "build": "gatsby build",
     "deploy": "gatsby build && gh-pages -b master -d public",
    "fix-semi": "eslint --quiet --ignore-pattern node_modules --ignore-pattern public --parser babel-eslint --no-eslintrc --rule '{\"semi\": [2, \"never\"], \"no-extra-semi\": [2]}' --fix gatsby-node.js"
  },
  "devDependencies": {
  "gh-pages": "^1.1.0",
  "prettier": "^1.12.0"
  }
}

和gatsby-config.sj:

module.exports = {
  siteMetadata: {
    title: "Gatsby Starter - Dimension by HTML5 UP",
    author: "Hunter Chang",
    description: "A Gatsby.js Starter based on Dimension by HTML5 UP"
  },
  pathPrefix: '/',
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/posts`,
        name: "posts",
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 630,
            },
          },
          "gatsby-remark-copy-linked-files",
        ],
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-sass`
  ],
}

1 个答案:

答案 0 :(得分:4)

让它工作!我没有安装这个:

npm install gh-pages --save-dev