Gatsby build fails on netifly

My gatsby build runs fine locally, but whenever I try to deploy to netlify it crashes.

using default settings on netlify
Here is the log when deploying the site:
8:48:11 PM: Build ready to start
8:48:12 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
8:48:12 PM: build-image tag: v3.3.20
8:48:12 PM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
8:48:13 PM: Fetching cached dependencies
8:48:13 PM: Starting to download cache of 254.8KB
8:48:13 PM: Finished downloading cache in 74.152128ms
8:48:13 PM: Starting to extract cache
8:48:13 PM: Failed to fetch cache, continuing with build
8:48:13 PM: Starting to prepare the repo for build
8:48:13 PM: No cached dependencies found. Cloning fresh repo
8:48:13 PM: git clone git@github.com:satyammahajan46/gatsby-satyam-portfolio
8:48:14 PM: Preparing Git Reference refs/heads/master
8:48:16 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘public’ versus ‘public/’ in the Netlify UI
8:48:16 PM: Starting build script
8:48:16 PM: Installing dependencies
8:48:16 PM: Python version set to 2.7
8:48:17 PM: v12.18.0 is already installed.
8:48:18 PM: Now using node v12.18.0 (npm v6.14.4)
8:48:18 PM: Started restoring cached build plugins
8:48:18 PM: Finished restoring cached build plugins
8:48:18 PM: Attempting ruby version 2.7.1, read from environment
8:48:20 PM: Using ruby version 2.7.1
8:48:20 PM: Using PHP version 5.6
8:48:20 PM: 5.2 is already installed.
8:48:20 PM: Using Swift version 5.2
8:48:20 PM: Started restoring cached node modules
8:48:20 PM: Finished restoring cached node modules
8:48:21 PM: Installing NPM modules using NPM version 6.14.4
8:49:08 PM: > sharp@0.25.4 install /opt/build/repo/node_modules/sharp
8:49:08 PM: > (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
8:49:08 PM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz
8:49:10 PM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
8:49:10 PM: > node scripts/install.js
8:49:11 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
8:49:11 PM: Download complete
8:49:11 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
8:49:11 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-72_binding.node
8:49:12 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
8:49:12 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
8:49:12 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/core-js
8:49:12 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
8:49:12 PM: > core-js-pure@3.6.5 postinstall /opt/build/repo/node_modules/core-js-pure
8:49:12 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
8:49:13 PM: > gatsby-telemetry@1.3.23 postinstall /opt/build/repo/node_modules/gatsby-telemetry
8:49:13 PM: > node src/postinstall.js || true
8:49:13 PM: > mozjpeg@6.0.1 postinstall /opt/build/repo/node_modules/mozjpeg
8:49:13 PM: > node lib/install.js
8:49:14 PM: :heavy_check_mark: mozjpeg pre-build test passed successfully
8:49:14 PM: > pngquant-bin@5.0.2 postinstall /opt/build/repo/node_modules/pngquant-bin
8:49:14 PM: > node lib/install.js
8:49:14 PM: :heavy_check_mark: pngquant pre-build test passed successfully
8:49:14 PM: > gatsby-cli@2.12.66 postinstall /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli
8:49:14 PM: > node scripts/postinstall.js
8:49:14 PM: > gatsby@2.24.11 postinstall /opt/build/repo/node_modules/gatsby
8:49:14 PM: > node scripts/postinstall.js
8:49:15 PM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
8:49:15 PM: > node scripts/build.js
8:49:15 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
8:49:15 PM: Testing binary
8:49:15 PM: Binary is fine
8:49:18 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/watchpack/node_modules/fsevents):
8:49:18 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
8:49:18 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
8:49:18 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
8:49:18 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
8:49:18 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
8:49:18 PM: added 2390 packages from 1317 contributors and audited 2397 packages in 55.538s
8:49:20 PM: 146 packages are looking for funding
8:49:20 PM: run npm fund for details
8:49:20 PM: found 0 vulnerabilities
8:49:20 PM: NPM modules installed
8:49:21 PM: Started restoring cached go cache
8:49:21 PM: Finished restoring cached go cache
8:49:21 PM: go version go1.14.4 linux/amd64
8:49:21 PM: go version go1.14.4 linux/amd64
8:49:21 PM: Installing missing commands
8:49:21 PM: Verify run directory
8:49:22 PM: ​
8:49:22 PM: ┌─────────────────────────────┐
8:49:22 PM: │ Netlify Build │
8:49:22 PM: └─────────────────────────────┘
8:49:22 PM: ​
8:49:22 PM: ❯ Version
8:49:22 PM: @netlify/build 3.0.1
8:49:22 PM: ​
8:49:22 PM: ❯ Flags
8:49:22 PM: deployId: 5f1bab7ae1fe1b7b5c80235a
8:49:22 PM: mode: buildbot
8:49:22 PM: ​
8:49:22 PM: ❯ Current directory
8:49:22 PM: /opt/build/repo
8:49:22 PM: ​
8:49:22 PM: ❯ Config file
8:49:22 PM: No config file was defined: using default values.
8:49:22 PM: ​
8:49:22 PM: ❯ Context
8:49:22 PM: production
8:49:22 PM: ​
8:49:22 PM: ┌───────────────────────────────────┐
8:49:22 PM: │ 1. Build command from Netlify app │
8:49:22 PM: └───────────────────────────────────┘
8:49:22 PM: ​
8:49:22 PM: $ gatsby build
8:49:25 PM: success open and validate gatsby-configs - 0.045s
8:49:26 PM: success load plugins - 1.021s
8:49:26 PM: success onPreInit - 0.011s
8:49:26 PM: success delete html and css files from previous builds - 0.012s
8:49:26 PM: success initialize cache - 0.008s
8:49:26 PM: success copy gatsby files - 0.046s
8:49:26 PM: success onPreBootstrap - 0.010s
8:49:26 PM: success createSchemaCustomization - 0.009s
8:49:27 PM: success Checking for changed pages - 0.000s
8:49:27 PM: success source and transform nodes - 0.760s
8:49:27 PM: success building schema - 0.351s
8:49:28 PM: success createPages - 0.283s
8:49:28 PM: success Checking for changed pages - 0.000s
8:49:28 PM: success createPagesStatefully - 0.157s
8:49:28 PM: success updating schema - 0.051s
8:49:28 PM: success onPreExtractQueries - 0.001s
8:49:29 PM: success extract queries from components - 0.731s
8:49:29 PM: success write out redirect data - 0.001s
8:49:29 PM: success Build manifest and related icons - 0.298s
8:49:29 PM: success onPostBootstrap - 0.300s
8:49:29 PM: info bootstrap finished - 6.998s
8:49:29 PM: success run static queries - 0.015s - 1/1 68.96/s
8:49:29 PM: success run page queries - 0.354s - 10/10 28.28/s
8:49:29 PM: success write out requires - 0.005s
8:50:07 PM: failed Building production JavaScript and CSS bundles - 37.944s
8:50:07 PM: error Generating JavaScript bundles failed
8:50:07 PM: Can’t resolve ‘…/…/public/static/d/2924840780.json’ in ‘/opt/build/repo/src/components’
8:50:07 PM: If you’re trying to use a package make sure that ‘…/…/public/static/d/2924840780.json’ is installed. If you’re trying to use a local file make sure that the path is correct.
8:50:07 PM: ​
8:50:07 PM: ┌─────────────────────────────┐
8:50:07 PM: │ “build.command” failed │
8:50:07 PM: └─────────────────────────────┘
8:50:07 PM: ​
8:50:07 PM: Error message
8:50:07 PM: Command failed with exit code 1: gatsby build
8:50:07 PM: ​
8:50:07 PM: Error location
8:50:07 PM: In Build command from Netlify app:
8:50:07 PM: gatsby build
8:50:07 PM: ​
8:50:07 PM: Resolved config
8:50:07 PM: build:
8:50:07 PM: command: gatsby build
8:50:07 PM: commandOrigin: ui
8:50:07 PM: publish: /opt/build/repo/public
8:50:07 PM: Caching artifacts
8:50:07 PM: Started saving node modules
8:50:07 PM: Finished saving node modules
8:50:07 PM: Started saving build plugins
8:50:07 PM: Finished saving build plugins
8:50:07 PM: Started saving pip cache
8:50:08 PM: Finished saving pip cache
8:50:08 PM: Started saving emacs cask dependencies
8:50:08 PM: Finished saving emacs cask dependencies
8:50:08 PM: Started saving maven dependencies
8:50:08 PM: Finished saving maven dependencies
8:50:08 PM: Started saving boot dependencies
8:50:08 PM: Finished saving boot dependencies
8:50:08 PM: Started saving go dependencies
8:50:08 PM: Finished saving go dependencies
8:50:14 PM: Error running command: Build script returned non-zero exit code: 1
8:50:14 PM: Failing build: Failed to build site
8:50:14 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
8:50:14 PM: Finished processing build request in 2m1.933466398s

Any suggestion and help will be appreciated? :frowning:

Hi, @satyammahajan46, it appears you resolved this about six minutes after this was posted.

​Please let us know if there are still questions about this. Likewise, we’d love to learn what your solution was if you are willing to share it. :+1:

So what I had to do is! I ended up improvising the file structure so complier doesny complain.

  1. Ran build command locally.
  2. Use the that sam public folder in my github repo.
  3. Renamed the local build public/static/d/xxxxxzx.json to public/static/d/2924840780.json
  4. Run netlify command to start build on server.

I personally believe it has something to do with static query which is a dependency of the gatsby graphql. Maybe, I am not sure. But I had to improvise the file structure to get my site running

thanks for sharing your approach!