【问题标题】:I'm trying to deploy my Gatsby Blog on Github pages, but "npm run deploy" returns error我正在尝试在 Github 页面上部署我的 Gatsby 博客,但“npm run deploy”返回错误
【发布时间】:2019-02-24 14:09:02
【问题描述】:

我尝试在 github 页面上构建和部署我的 Gatsby 博客。 我关注了盖茨比关于部署的文档:https://www.gatsbyjs.org/docs/deploy-gatsby/

我运行以下命令:

npm run deploy

我遇到过:

Cannot read property 'email' of null
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-starter-hello-world@ deploy: `gatsby build && gh-pages -b master -d public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-starter-hello-world@ 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/ChaewonKong/.npm/_logs/2018-09-20T09_34_57_114Z-debug.log

这是我的 gatsby-config.js 的样子:

module.exports = {
  siteMetadata: {
    title: `Leon Kong's Blog`
  },
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `src`,
        path: `${__dirname}/src/`
      }
    },
    `gatsby-transformer-remark`
  ]
};

这是我的 package.json:

{
  "name": "gatsby-starter-hello-world",
  "description": "Gatsby hello world starter",
  "license": "MIT",
  "scripts": {
    "develop": "gatsby develop",
    "build": "gatsby build",
    "serve": "gatsby serve",
    "deploy": "gatsby build && gh-pages -b master -d public"
  },
  "dependencies": {
    "gatsby": "^2.0.0",
    "gatsby-source-filesystem": "^2.0.1",
    "gatsby-transformer-remark": "^2.1.3",
    "react": "^16.5.1",
    "react-dom": "^16.5.1"
  },
   "devDependencies": {
    "gh-pages": "^2.0.0"
  }
}

另外,我正在尝试制作一个用户/组织网站,例如: https://username/github.io

【问题讨论】:

    标签: reactjs github npm github-pages gatsby


    【解决方案1】:

    我只是猜测你的 git 配置中没有设置电子邮件。尝试运行git config user.email 看看它是否存在。

    你可以关注这篇文章了解如何添加它https://help.github.com/articles/setting-your-commit-email-address-in-git/

    另外,这里是docs on how to set a github page

    【讨论】:

    • 好吧,这很奇怪。我尝试在.gitconfig 中评论我的电子邮件并收到相同的错误消息。您可以尝试另一种选择 - 将用户设置添加到 package.json 中的 deploy 脚本中,如下所示:"deploy": "gatsby build && gh-pages -b master -d public --user \"Your Name <your@email.com>\"",
    猜你喜欢
    • 1970-01-01
    • 2022-09-23
    • 1970-01-01
    • 2022-10-17
    • 2021-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    相关资源
    最近更新 更多