Gatsby Site runs locally, but fails to deploy on Netlify

Just as the title says my site won’t deploy. I have checked for any case sensitivity issues and even renamed the file. It seems like maybe something is going wrong with my graphql query? Here is my log:

11:39:17 AM: Build ready to start
11:39:19 AM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
11:39:19 AM: build-image tag: v3.6.1
11:39:19 AM: buildbot version: 7e537c561b769a40f753e191ab4920a012130b8d
11:39:19 AM: Fetching cached dependencies
11:39:19 AM: Failed to fetch cache, continuing with build
11:39:19 AM: Starting to prepare the repo for build
11:39:20 AM: No cached dependencies found. Cloning fresh repo
11:39:20 AM: git clone GitHub - zorro1rr/MarianneYoga: Personal yoga website
11:39:21 AM: Preparing Git Reference refs/heads/master
11:39:23 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: β€˜Gatsby/public’ versus β€˜public’ in the Netlify UI
11:39:23 AM: Starting build script
11:39:23 AM: Installing dependencies
11:39:23 AM: Python version set to 2.7
11:39:24 AM: v12.18.0 is already installed.
11:39:25 AM: Now using node v12.18.0 (npm v6.14.4)
11:39:25 AM: Started restoring cached build plugins
11:39:25 AM: Finished restoring cached build plugins
11:39:25 AM: Attempting ruby version 2.7.1, read from environment
11:39:27 AM: Using ruby version 2.7.1
11:39:27 AM: Using PHP version 5.6
11:39:27 AM: Started restoring cached node modules
11:39:27 AM: Finished restoring cached node modules
11:39:28 AM: Installing NPM modules using NPM version 6.14.4
11:40:27 AM: > bufferutil@4.0.2 install /opt/build/repo/Gatsby/node_modules/bufferutil
11:40:27 AM: > node-gyp-build
11:40:28 AM: > utf-8-validate@5.0.3 install /opt/build/repo/Gatsby/node_modules/utf-8-validate
11:40:28 AM: > node-gyp-build
11:40:29 AM: > sharp@0.25.4 install /opt/build/repo/Gatsby/node_modules/sharp
11:40:29 AM: > (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
11:40:30 AM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz
11:40:32 AM: > core-js@2.6.11 postinstall /opt/build/repo/Gatsby/node_modules/babel-runtime/node_modules/core-js
11:40:32 AM: > node -e β€œtry{require(β€˜./postinstall’)}catch(e){}”
11:40:33 AM: > core-js@3.7.0 postinstall /opt/build/repo/Gatsby/node_modules/core-js
11:40:33 AM: > node -e β€œtry{require(β€˜./postinstall’)}catch(e){}”
11:40:33 AM: > core-js-pure@3.7.0 postinstall /opt/build/repo/Gatsby/node_modules/core-js-pure
11:40:33 AM: > node -e β€œtry{require(β€˜./postinstall’)}catch(e){}”
11:40:34 AM: > gatsby-telemetry@1.4.1 postinstall /opt/build/repo/Gatsby/node_modules/gatsby-telemetry
11:40:34 AM: > node src/postinstall.js || true
11:40:35 AM: > mozjpeg@7.0.0 postinstall /opt/build/repo/Gatsby/node_modules/mozjpeg
11:40:35 AM: > node lib/install.js
11:40:35 AM: :heavy_check_mark: mozjpeg pre-build test passed successfully
11:40:35 AM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/Gatsby/node_modules/pngquant-bin
11:40:35 AM: > node lib/install.js
11:40:36 AM: :heavy_check_mark: pngquant pre-build test passed successfully
11:40:36 AM: > gatsby-cli@2.13.1 postinstall /opt/build/repo/Gatsby/node_modules/gatsby/node_modules/gatsby-cli
11:40:36 AM: > node scripts/postinstall.js
11:40:36 AM: > gatsby@2.26.1 postinstall /opt/build/repo/Gatsby/node_modules/gatsby
11:40:36 AM: > node scripts/postinstall.js
11:40:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
11:40:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œlinux”,β€œarch”:β€œx64”})
11:40:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
11:40:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œlinux”,β€œarch”:β€œx64”})
11:40:40 AM: added 2415 packages from 1328 contributors and audited 2422 packages in 71.042s
11:40:43 AM: 176 packages are looking for funding
11:40:43 AM: run npm fund for details
11:40:43 AM: found 16 vulnerabilities (13 low, 3 high)
11:40:43 AM: run npm audit fix to fix them, or npm audit for details
11:40:43 AM: NPM modules installed
11:40:43 AM: Started restoring cached go cache
11:40:43 AM: Finished restoring cached go cache
11:40:43 AM: go version go1.14.4 linux/amd64
11:40:43 AM: go version go1.14.4 linux/amd64
11:40:43 AM: Installing missing commands
11:40:43 AM: Verify run directory
11:40:45 AM: ​
11:40:45 AM: ────────────────────────────────────────────────────────────────
11:40:45 AM: Netlify Build
11:40:45 AM: ────────────────────────────────────────────────────────────────
11:40:45 AM: ​
11:40:45 AM: ❯ Version
11:40:45 AM: @netlify/build 9.1.0
11:40:45 AM: ​
11:40:45 AM: ❯ Flags
11:40:45 AM: deployId: 602579d5349a060007d824c3
11:40:45 AM: mode: buildbot
11:40:45 AM: ​
11:40:45 AM: ❯ Current directory
11:40:45 AM: /opt/build/repo/Gatsby
11:40:45 AM: ​
11:40:45 AM: ❯ Config file
11:40:45 AM: No config file was defined: using default values.
11:40:45 AM: ​
11:40:45 AM: ❯ Context
11:40:45 AM: production
11:40:45 AM: ​
11:40:45 AM: ────────────────────────────────────────────────────────────────
11:40:45 AM: 1. Build command from Netlify app
11:40:45 AM: ────────────────────────────────────────────────────────────────
11:40:45 AM: ​
11:40:45 AM: $ npm run build
11:40:45 AM: > gatsby-starter-default@0.1.0 build /opt/build/repo/Gatsby
11:40:45 AM: > gatsby build
11:40:49 AM: success open and validate gatsby-configs - 0.027s
11:40:50 AM: success load plugins - 1.146s
11:40:50 AM: success onPreInit - 0.045s
11:40:50 AM: success delete html and css files from previous builds - 0.003s
11:40:50 AM: success initialize cache - 0.008s
11:40:50 AM: success copy gatsby files - 0.043s
11:40:50 AM: info [sanity] Fetching remote GraphQL schema
11:40:51 AM: info [sanity] Transforming to Gatsby-compatible GraphQL SDL
11:40:51 AM: info [sanity] Stitching GraphQL schemas from SDL
11:40:51 AM: success onPreBootstrap - 0.261s
11:40:51 AM: success createSchemaCustomization - 0.011s
11:40:51 AM: info [sanity] Fetching export stream for dataset
11:40:51 AM: info [sanity] Done! Exported 17 documents.
11:40:51 AM: success Checking for changed pages - 0.000s
11:40:51 AM: success source and transform nodes - 0.542s
11:40:52 AM: success building schema - 0.596s
11:40:52 AM: info Total nodes: 90, SitePage nodes: 1 (use --verbose for breakdown)
11:40:52 AM: success createPages - 0.001s
11:40:52 AM: success Checking for changed pages - 0.000s
11:40:52 AM: success createPagesStatefully - 0.124s
11:40:52 AM: success update schema - 0.036s
11:40:52 AM: success onPreExtractQueries - 0.005s
11:40:53 AM: success extract queries from components - 1.066s
11:40:53 AM: success write out redirect data - 0.001s
11:40:53 AM: success Build manifest and related icons - 0.259s
11:40:53 AM: success onPostBootstrap - 0.261s
11:40:53 AM: info bootstrap finished - 7.849s
11:40:54 AM: success run page queries - 0.740s - 7/7 9.46/s
11:40:54 AM: success write out requires - 0.007s
11:41:29 AM: success Building production JavaScript and CSS bundles - 35.215s
11:41:30 AM: success Rewriting compilation hashes - 0.005s
11:41:36 AM: {
11:41:36 AM: file: null,
11:41:36 AM: footerLotus: null,
11:41:36 AM: pilates: null,
11:41:36 AM: pose: null,
11:41:36 AM: split: null,
11:41:36 AM: allSanitySeo: { nodes: [ [Object] ] }
11:41:36 AM: }
11:41:36 AM: failed Building static HTML for pages - 6.430s
11:41:36 AM: error Building static HTML failed for path β€œ/about/”
11:41:36 AM:
11:41:36 AM: 227 |
11:41:36 AM: 228 |


11:41:36 AM: > 229 |
11:41:36 AM: | ^
11:41:36 AM: 230 |

My Journey


11:41:36 AM: 231 |

11:41:36 AM: 232 |
11:41:36 AM:
11:41:36 AM: WebpackError: TypeError: Cannot read property β€˜childImageSharp’ of null
11:41:36 AM:
11:41:36 AM: - about.js:229
11:41:36 AM: src/pages/about.js:229:33
11:41:36 AM:
11:41:36 AM:
11:41:36 AM: not finished Generating image thumbnails - 42.715s
11:41:36 AM: npm ERR! code ELIFECYCLE
11:41:36 AM: npm ERR! errno 1
11:41:36 AM: npm ERR! gatsby-starter-default@0.1.0 build: gatsby build
11:41:36 AM: npm ERR! Exit status 1
11:41:36 AM: npm ERR!
11:41:36 AM: npm ERR! Failed at the gatsby-starter-default@0.1.0 build script.
11:41:36 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
11:41:36 AM: npm ERR! A complete log of this run can be found in:
11:41:36 AM: npm ERR! /opt/buildhome/.npm/_logs/2021-02-11T18_41_36_739Z-debug.log
11:41:36 AM: ​
11:41:36 AM: ────────────────────────────────────────────────────────────────
11:41:36 AM: β€œbuild.command” failed
11:41:36 AM: ────────────────────────────────────────────────────────────────
11:41:36 AM: ​
11:41:36 AM: Error message
11:41:36 AM: Command failed with exit code 1: npm run build
11:41:36 AM: ​
11:41:36 AM: Error location
11:41:36 AM: In Build command from Netlify app:
11:41:36 AM: npm run build
11:41:36 AM: ​
11:41:36 AM: Resolved config
11:41:36 AM: build:
11:41:36 AM: base: /opt/build/repo/Gatsby
11:41:36 AM: command: npm run build
11:41:36 AM: commandOrigin: ui
11:41:36 AM: environment:
11:41:36 AM: - SANITY_TOKEN
11:41:36 AM: publish: /opt/build/repo/Gatsby/public
11:41:36 AM: Caching artifacts
11:41:36 AM: Started saving node modules
11:41:36 AM: Finished saving node modules
11:41:36 AM: Started saving build plugins
11:41:36 AM: Finished saving build plugins
11:41:36 AM: Started saving pip cache
11:41:37 AM: Finished saving pip cache
11:41:37 AM: Started saving emacs cask dependencies
11:41:37 AM: Finished saving emacs cask dependencies
11:41:37 AM: Started saving maven dependencies
11:41:37 AM: Finished saving maven dependencies
11:41:37 AM: Started saving boot dependencies
11:41:37 AM: Finished saving boot dependencies
11:41:37 AM: Started saving rust rustup cache
11:41:37 AM: Finished saving rust rustup cache
11:41:37 AM: Started saving go dependencies
11:41:37 AM: Finished saving go dependencies
11:41:40 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:41:40 AM: Failing build: Failed to build site
11:41:40 AM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
11:41:40 AM: Finished processing build request in 2m21.012441371s

Your GraphQL query indeed seems to be wrong. I changed all the queries in the about file to:

    file(relativePath: {eq: "about/lotus2.png"}) {
      childImageSharp {
        fixed(width: 400, height: 240) {
          ...GatsbyImageSharpFixed
        }
      }
    }
    footerLotus: file(relativePath: {eq: "about/LotusBottom.png"}) {
      childImageSharp {
        fixed {
          ...GatsbyImageSharpFixed
        }
      }
    }
    pilates: file(relativePath: {eq: "about/Yogi-15.jpg"}) {
      childImageSharp {
        fluid(maxWidth: 648, quality: 100) {
          ...GatsbyImageSharpFluid
        }
      }
    }
    pose: file(relativePath: {eq: "about/Yogi-8.jpg"}) {
      childImageSharp {
        fluid(maxWidth: 360, quality: 100) {
          ...GatsbyImageSharpFluid
        }
      }
    }
    split: file(relativePath: {eq: "about/Yogi-30.jpg"}) {
      childImageSharp {
        fluid(maxWidth: 648, quality: 100) {
          ...GatsbyImageSharpFluid
        }
      }
    }

and it seems to work. I mean, now I don’t get any more errors in the about page and have now Gatsby throws errors for the home page. I believe, if you fix them in a similar way, it’d work.

Note: I have guessed the names of the files and they might be wrong, so make the changes accordingly. I have just fixed the wrong queries.

2 Likes

That worked! Thank you so much!