I have struggle with building gatsby site. When I enter to my console 'gatsby develop', my app starts. 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
"
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
/**
* 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
{
"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}
to 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.