简体   繁体   English

盖茨比网站无法建立

[英]Gatsby site couldn't be build

I have struggle with building gatsby site.我在构建 gatsby 网站时遇到了困难。 When I enter to my console 'gatsby develop', my app starts.当我进入我的控制台“gatsby develop”时,我的应用程序启动了。 But when I try build, I see errors like below.但是当我尝试构建时,我看到如下错误。 Anyone knows how to resolve this?任何人都知道如何解决这个问题? SCREENSHOT截屏

I tried reinstall dependencies, reproduce, use yarn and npm, build in gatsby-cloud,.netlify and console, delete node-modules and package-lock.json我尝试重新安装依赖项,重现,使用 yarn 和 npm,构建 gatsby-cloud,.netlify 和控制台,删除节点模块和 package-lock.json

"

ERROR  UNKNOWN

Truncated page data information for the failed page "/": {
  "errors": {},
  "path": "/",
  "slicesMap": {},
  "pageContext": {}
}

failed Building static HTML for pages - 8.327s

 ERROR #95313  HTML.COMPILATION

Building static HTML failed for path "/"

See our docs page for more info on this error: https://gatsby.dev/debug-html


  WebpackError: TypeError: Cannot read properties of undefined (reading 'fallback')

 - gatsby-image.server.tsx:62 
    webpack:/gatsby-starter-default/src/components/gatsby-image.server.tsx:62:16

  - index.esm.js:40 
    [gatsby-starter-default]/[react-icons]/ai/index.esm.js:40:39

  - index.esm.js:42 
    [gatsby-starter-default]/[react-icons]/ai/index.esm.js:42:8

  - index.esm.js:48 
    [gatsby-starter-default]/[react-icons]/ai/index.esm.js:48:8

  - index.esm.js:51 
    [gatsby-starter-default]/[react-icons]/ai/index.esm.js:51:8

"

gatsby-config.js盖茨比-config.js

/**
 * Configure your Gatsby site with this file.
 *
 * See: https://www.gatsbyjs.com/docs/reference/config-files/gatsby-config/
 */

/**
 * @type {import('gatsby').GatsbyConfig}
 */
module.exports = {
  siteMetadata: {
    title: `project`,
    description: ``,
    author: `@author`,
    siteUrl: `https://gatsbystarterdefaultsource.gatsbyjs.io/`,
  },
  flags: {
    DEV_SSR: true
  },
  plugins: [
    {
      resolve: "gatsby-source-wordpress",
      options: {
        url: ``,
        schema: {
          timeout: 1000000,
          perPage: 10,
          requestConcurrency: 5,
        },
      },
    },
    `gatsby-plugin-image`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        // This will impact how browsers show your PWA/website
        // https://css-tricks.com/meta-theme-color-and-trickery/
        // theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
    {
      resolve: '@chakra-ui/gatsby-plugin',
      options: {
        /**
         * @property {boolean} [resetCSS=true]
         * if false, this plugin will not use `<CSSReset />
         */
        resetCSS: true,
        /**
         * @property {boolean} [isUsingColorMode=true]
         * if false, this plugin will not use <ColorModeProvider />
         */
        isUsingColorMode: true,
      },
    },
    `gatsby-plugin-transition-link`
  ],
}

package.json package.json

{
  "name": "gatsby-starter-default",
  "private": true,
  "description": "A simple starter to get up and developing quickly with Gatsby",
  "version": "0.1.0",
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
  "dependencies": {
    "@chakra-ui/gatsby-plugin": "^3.1.1",
    "@chakra-ui/react": "^2.4.6",
    "@emotion/react": "^11.10.5",
    "@emotion/styled": "^11.10.5",
    "@fontsource/kaushan-script": "^4.5.10",
    "@fontsource/mulish": "^4.5.13",
    "@fontsource/spartan": "^4.5.8",
    "firebase": "^9.15.0",
    "formik": "^2.2.9",
    "framer-motion": "^8.1.3",
    "gatsby": "^5.3.3",
    "gatsby-image": "^3.11.0",
    "gatsby-plugin-image": "^3.3.2",
    "gatsby-plugin-manifest": "^5.3.1",
    "gatsby-plugin-sharp": "^5.3.2",
    "gatsby-source-filesystem": "^5.3.1",
    "gatsby-source-wordpress": "^7.3.2",
    "gatsby-transformer-sharp": "^5.3.1",
    "gsap": "^3.11.4",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.7.1",
    "react-scroll-parallax": "^3.3.2",
    "webpack": "^5.75.0"
  },
  "devDependencies": {
    "prettier": "^2.8.0"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "0BSD",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md,css}\"",
    "start": "gatsby develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}

I resolved this problem.我解决了这个问题。 I changed line img={post.featuredImage || photo}我更改了行img={post.featuredImage || photo} img={post.featuredImage || photo} to img={post?.featuredImage || photo} img={post.featuredImage || photo}img={post?.featuredImage || photo} img={post?.featuredImage || photo} . img={post?.featuredImage || photo} Line of code needed Optional Chaining.代码行需要可选链接。 Later I had same error and I changed GatsbyImage component to Image component by ChakraUI.后来我有同样的错误,我通过 ChakraUI 将 GatsbyImage 组件更改为 Image 组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM