Gatsby build - failed Building production JavaScript and CSS bundles

Hi there,

I’m having issues with my Gatsby build. I have been trying to get a custom npm package working on the site and I have managed to get it working locally but fails when deploying to Netlify. I have tried resetting the package-lock and the “clear cache and deploy site” option, but getting the same error.

Here’s the site - https://hardcore-jones-443429.netlify.app/ - currently running old site with no custom npm package since build fails.

Here’s my build log -

2:17:06 PM: Build ready to start
2:17:08 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
2:17:08 PM: build-image tag: v3.4.1
2:17:08 PM: buildbot version: fcbc7a79f7372e5995cf02954ef19fc48d20c871
2:17:08 PM: Fetching cached dependencies
2:17:08 PM: Starting to download cache of 159.6MB
2:17:09 PM: Finished downloading cache in 1.25497458s
2:17:09 PM: Starting to extract cache
2:17:20 PM: Finished extracting cache in 10.616967778s
2:17:20 PM: Finished fetching cache in 11.914826694s
2:17:20 PM: Starting to prepare the repo for build
2:17:20 PM: Preparing Git Reference refs/heads/master
2:17:22 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
2:17:23 PM: Starting build script
2:17:23 PM: Installing dependencies
2:17:23 PM: Python version set to 2.7
2:17:23 PM: Started restoring cached node version
2:17:26 PM: Finished restoring cached node version
2:17:26 PM: v12.18.0 is already installed.
2:17:27 PM: Now using node v12.18.0 (npm v6.14.4)
2:17:27 PM: Started restoring cached build plugins
2:17:27 PM: Finished restoring cached build plugins
2:17:27 PM: Attempting ruby version 2.7.1, read from environment
2:17:29 PM: Using ruby version 2.7.1
2:17:29 PM: Using PHP version 5.6
2:17:29 PM: 5.2 is already installed.
2:17:29 PM: Using Swift version 5.2
2:17:29 PM: Started restoring cached node modules
2:17:29 PM: Finished restoring cached node modules
2:17:29 PM: Installing NPM modules using NPM version 6.14.4
2:18:10 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/gatsby/node_modules/core-js
2:18:10 PM: > node -e "try{require('./postinstall')}catch(e){}"
2:18:10 PM: > gatsby-telemetry@1.3.28 postinstall /opt/build/repo/node_modules/gatsby-telemetry
2:18:10 PM: > node src/postinstall.js || true
2:18:10 PM: > gatsby-cli@2.12.88 postinstall /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli
2:18:10 PM: > node scripts/postinstall.js
2:18:11 PM: > gatsby@2.24.47 postinstall /opt/build/repo/node_modules/gatsby
2:18:11 PM: > node scripts/postinstall.js
2:18:14 PM: npm WARN @pmmmwh/react-refresh-webpack-plugin@0.3.3 requires a peer of react-refresh@^0.8.2 but none is installed. You must install peer dependencies yourself.
2:18:14 PM: npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
2:18:14 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/watchpack/node_modules/fsevents):
2:18:14 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:18:14 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
2:18:14 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:18:14 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
2:18:14 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:18:14 PM: added 307 packages from 126 contributors, removed 273 packages and updated 335 packages in 43.387s
2:18:16 PM: 154 packages are looking for funding
2:18:16 PM:   run `npm fund` for details
2:18:16 PM: NPM modules installed
2:18:16 PM: Started restoring cached go cache
2:18:16 PM: Finished restoring cached go cache
2:18:17 PM: go version go1.14.4 linux/amd64
2:18:17 PM: go version go1.14.4 linux/amd64
2:18:17 PM: Installing missing commands
2:18:17 PM: Verify run directory
2:18:18 PM: ​
2:18:18 PM: ┌─────────────────────────────┐
2:18:18 PM: │        Netlify Build        │
2:18:18 PM: └─────────────────────────────┘
2:18:18 PM: ​
2:18:18 PM: ❯ Version
2:18:18 PM:   @netlify/build 3.3.0
2:18:18 PM: ​
2:18:18 PM: ❯ Flags
2:18:18 PM:   deployId: 5f4660d243e34d0007a81fa4
2:18:18 PM:   mode: buildbot
2:18:18 PM: ​
2:18:18 PM: ❯ Current directory
2:18:18 PM:   /opt/build/repo
2:18:18 PM: ​
2:18:18 PM: ❯ Config file
2:18:18 PM:   No config file was defined: using default values.
2:18:18 PM: ​
2:18:18 PM: ❯ Context
2:18:18 PM:   production
2:18:18 PM: ​
2:18:18 PM: ┌───────────────────────────────────┐
2:18:18 PM: │ 1. Build command from Netlify app │
2:18:18 PM: └───────────────────────────────────┘
2:18:18 PM: ​
2:18:18 PM: $ gatsby build
2:18:22 PM: success open and validate gatsby-configs - 0.032s
2:18:23 PM: success load plugins - 0.982s
2:18:24 PM: success onPreInit - 0.050s
2:18:24 PM: success delete html and css files from previous builds - 0.008s
2:18:24 PM: success initialize cache - 0.013s
2:18:24 PM: success copy gatsby files - 0.047s
2:18:24 PM: success onPreBootstrap - 0.011s
2:18:24 PM: success createSchemaCustomization - 0.008s
2:18:25 PM: success Checking for changed pages - 0.000s
2:18:25 PM: success source and transform nodes - 0.993s
2:18:25 PM: success building schema - 0.449s
2:18:25 PM: success createPages - 0.211s
2:18:25 PM: success Checking for changed pages - 0.000s
2:18:25 PM: success createPagesStatefully - 0.088s
2:18:26 PM: success update schema - 0.062s
2:18:26 PM: success onPreExtractQueries - 0.001s
2:18:26 PM: warning Using the global `graphql` tag is deprecated, and will not be supported in v3.
2:18:26 PM: Import it instead like:  import { graphql } from 'gatsby' in file:
2:18:26 PM: /opt/build/repo/src/queries/useNavigation.js
2:18:26 PM: success extract queries from components - 0.900s
2:18:26 PM: success write out redirect data - 0.001s
2:18:27 PM: success Build manifest and related icons - 0.350s
2:18:27 PM: success onPostBootstrap - 0.352s
2:18:27 PM: info bootstrap finished - 8.781s
2:18:27 PM: success run static queries - 0.184s - 2/2 10.85/s
2:18:27 PM: success run page queries - 0.216s - 5/5 23.19/s
2:18:27 PM: success write out requires - 0.006s
2:19:00 PM: failed Building production JavaScript and CSS bundles - 32.742s
2:19:00 PM: error Generating JavaScript bundles failed
2:19:00 PM: Can't resolve '../../public/static/d/4133374844.json' in '/opt/build/repo/src/queries'
2:19:00 PM: If you're trying to use a package make sure that '../../public/static/d/4133374844.json' is installed. If you're trying to use a local file make sure that the path is correct.
2:19:00 PM: error Generating JavaScript bundles failed
2:19:00 PM: Can't resolve '../../public/static/d/63159454.json' in '/opt/build/repo/src/components'
2:19:00 PM: If you're trying to use a package make sure that '../../public/static/d/63159454.json' is installed. If you're trying to use a local file make sure that the path is correct.
2:19:00 PM: ​
2:19:00 PM: ┌─────────────────────────────┐
2:19:00 PM: │   "build.command" failed    │
2:19:00 PM: └─────────────────────────────┘
2:19:00 PM: ​
2:19:00 PM:   Error message
2:19:00 PM:   Command failed with exit code 1: gatsby build
2:19:00 PM: ​
2:19:00 PM:   Error location
2:19:00 PM:   In Build command from Netlify app:
2:19:00 PM:   gatsby build
2:19:00 PM: ​
2:19:00 PM:   Resolved config
2:19:00 PM:   build:
2:19:00 PM:     command: gatsby build
2:19:00 PM:     commandOrigin: ui
2:19:00 PM:     environment:
2:19:00 PM:       - READ_TOKEN
2:19:00 PM:     publish: /opt/build/repo/public
2:19:00 PM: Caching artifacts
2:19:00 PM: Started saving node modules
2:19:00 PM: Finished saving node modules
2:19:00 PM: Started saving build plugins
2:19:00 PM: Finished saving build plugins
2:19:00 PM: Started saving pip cache
2:19:00 PM: Finished saving pip cache
2:19:00 PM: Started saving emacs cask dependencies
2:19:00 PM: Finished saving emacs cask dependencies
2:19:00 PM: Started saving maven dependencies
2:19:00 PM: Finished saving maven dependencies
2:19:00 PM: Started saving boot dependencies
2:19:00 PM: Finished saving boot dependencies
2:19:00 PM: Started saving go dependencies
2:19:00 PM: Finished saving go dependencies
2:19:00 PM: Error running command: Build script returned non-zero exit code: 1
2:19:00 PM: Failing build: Failed to build site
2:19:00 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
2:19:01 PM: Finished processing build request in 1m52.792551328s

Any help would be appreciated, Thanks!

hi there, sorry to be slow to get back to you!

so you have a warning a little further up in your build log but that isn’t the reason why it’s failing - it is definitely this section that is causing problems.

First question is always: does it build locally?

I’m not 100% sure what is causing this behaviour but some basic troubleshooting can be found:

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile:

If that doesn’t help, let us know, and we’ll dig a bit more.

Hi thanks for the reply.

I’ve followed through the support guide and had no luck so far.

It does build and serve locally.

Any help would be appreciated.

Thanks!

This is probably a better guide for debugging your build - instead of some commonly encountered problems, it’s more of a step by step:

So once you’ve reviewed that, please confirm (from the guide) that:

  1. your project builds and serves locally from a clean copy of the repo?
  2. you’ve synced all of your yarn and node versions with Netlify’s?
  3. Let me know the answers to the questions near the end of that post

Thanks!