After adding react-router-dom to add queries to the end of the home page URL depending on filters selected, build fails everytime I try to deploy even though the site works perfectly when using gatsby develop locally

Here is a CodeSandbox link to the component I added to the site… https://codesandbox.io/s/jolly-mestorf-f8riy?file=/src/index.js:176-292

Because of the way my site is coded, I didn’t add it using ReactDOM like it does in the code sandbox, I instead added it to my component in the following files…
src/pages/index.js
src/components/AlgoliaInstantSearchCreateURLRefinementLists.js

I set those up so you can edit the code, so please feel free to edit it however needed to fix this issue.

It works so perfectly locally that I really want to be able to get it working on my live site, any help would be greatly appreciated.

Thanks,

Chris

Site Info
peaceful-knuth-b6b4b5
https://raidchamps.com/
4:49:36 PM: Build ready to start
4:49:38 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
4:49:38 PM: build-image tag: v3.3.20
4:49:38 PM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
4:49:38 PM: Fetching cached dependencies
4:49:39 PM: Starting to download cache of 226.6MB
4:49:41 PM: Finished downloading cache in 2.553362347s
4:49:41 PM: Starting to extract cache
4:49:51 PM: Finished extracting cache in 10.198801775s
4:49:51 PM: Finished fetching cache in 12.812213588s
4:49:51 PM: Starting to prepare the repo for build
4:49:52 PM: Preparing Git Reference refs/heads/master
4:49:53 PM: Starting build script
4:49:53 PM: Installing dependencies
4:49:53 PM: Python version set to 2.7
4:49:54 PM: Started restoring cached node version
4:49:56 PM: Finished restoring cached node version
4:49:57 PM: v12.18.0 is already installed.
4:49:57 PM: Now using node v12.18.0 (npm v6.14.4)
4:49:57 PM: Started restoring cached build plugins
4:49:57 PM: Finished restoring cached build plugins
4:49:57 PM: Attempting ruby version 2.7.1, read from environment
4:49:58 PM: Using ruby version 2.7.1
4:49:59 PM: Using PHP version 5.6
4:49:59 PM: 5.2 is already installed.
4:49:59 PM: Using Swift version 5.2
4:49:59 PM: Started restoring cached node modules
4:49:59 PM: Finished restoring cached node modules
4:49:59 PM: Started restoring cached yarn cache
4:49:59 PM: Finished restoring cached yarn cache
4:49:59 PM: Installing NPM modules using Yarn version 1.22.4
4:49:59 PM: yarn install v1.22.4
4:50:00 PM: [1/4] Resolving packages…
4:50:01 PM: [2/4] Fetching packages…
4:50:06 PM: warning url-loader@1.1.2: Invalid bin field for “url-loader”.
4:50:34 PM: info fsevents@2.1.3: The platform “linux” is incompatible with this module.
4:50:34 PM: info “fsevents@2.1.3” is an optional dependency and failed compatibility check. Excluding it from installation.
4:50:34 PM: info fsevents@1.2.13: The platform “linux” is incompatible with this module.
4:50:34 PM: info “fsevents@1.2.13” is an optional dependency and failed compatibility check. Excluding it from installation.
4:50:34 PM: info fsevents@2.1.2: The platform “linux” is incompatible with this module.
4:50:34 PM: info “fsevents@2.1.2” is an optional dependency and failed compatibility check. Excluding it from installation.
4:50:34 PM: [3/4] Linking dependencies…
4:50:34 PM: warning " > bootstrap@4.5.0" has unmet peer dependency “popper.js@^1.16.0”.
4:50:34 PM: warning “gatsby > @pmmmwh/react-refresh-webpack-plugin@0.3.3” has incorrect peer dependency “react-refresh@^0.8.2”.
4:50:34 PM: warning " > gatsby-link@2.4.8" has unmet peer dependency “@reach/router@^1.3.3”.
4:50:34 PM: warning “gatsby > @typescript-eslint/eslint-plugin > tsutils@3.17.1” has unmet peer dependency “typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta”.
4:50:34 PM: warning “gatsby-plugin-netlify > webpack-assets-manifest@3.1.1” has unmet peer dependency “webpack@>=4.4.0”.
4:50:34 PM: warning “instantsearch-tagsbox-react > react-instantsearch > react-instantsearch-native@5.7.0” has unmet peer dependency “react-native@>= 0.32.0”.
4:50:34 PM: warning “netlify-cms-app > netlify-cms-widget-code@1.2.0” has unmet peer dependency “codemirror@^5.46.0”.
4:50:34 PM: warning “netlify-cms-app > netlify-cms-widget-list@2.6.0” has unmet peer dependency “netlify-cms-lib-widgets@^1.0.0”.
4:50:34 PM: warning “netlify-cms-app > netlify-cms-widget-relation@2.8.0” has unmet peer dependency “netlify-cms-lib-widgets@^1.0.0”.
4:50:34 PM: warning “netlify-cms-app > netlify-cms-widget-code > react-codemirror2@6.0.1” has unmet peer dependency “codemirror@5.x”.
4:50:34 PM: warning “netlify-cms-app > netlify-cms-core > redux-notifications > react-redux@4.4.10” has incorrect peer dependency “redux@^2.0.0 || ^3.0.0”.
4:50:34 PM: warning “react-instantsearch > react-instantsearch-native@6.6.0” has unmet peer dependency “react-native@>= 0.54.0”.
4:50:34 PM: warning " > styled-components@5.1.1" has unmet peer dependency “react-is@>= 16.8.0”.
4:51:03 PM: [4/4] Building fresh packages…
4:51:13 PM: Done in 73.33s.
4:51:13 PM: NPM modules installed using Yarn
4:51:13 PM: Started restoring cached go cache
4:51:13 PM: Finished restoring cached go cache
4:51:13 PM: go version go1.14.4 linux/amd64
4:51:13 PM: go version go1.14.4 linux/amd64
4:51:13 PM: Installing missing commands
4:51:13 PM: Verify run directory
4:51:14 PM: ​
4:51:14 PM: ┌─────────────────────────────┐
4:51:14 PM: │ Netlify Build │
4:51:14 PM: └─────────────────────────────┘
4:51:14 PM: ​
4:51:14 PM: ❯ Version
4:51:14 PM: @netlify/build 3.0.1
4:51:14 PM: ​
4:51:14 PM: ❯ Flags
4:51:14 PM: deployId: 5f1c9ae0e8960d00081385a7
4:51:14 PM: mode: buildbot
4:51:14 PM: ​
4:51:14 PM: ❯ Current directory
4:51:14 PM: /opt/build/repo
4:51:14 PM: ​
4:51:14 PM: ❯ Config file
4:51:14 PM: /opt/build/repo/netlify.toml
4:51:14 PM: ​
4:51:14 PM: ❯ Context
4:51:14 PM: production
4:51:14 PM: ​
4:51:14 PM: ❯ Installing local plugins dependencies
4:51:14 PM: - ./plugins/netlify-plugin-algolia-index
4:51:16 PM: ​
4:51:16 PM: ❯ Loading plugins
4:51:16 PM: - ./plugins/netlify-plugin-algolia-index@1.0.2 from netlify.toml
4:51:17 PM: ​
4:51:17 PM: ┌────────────────────────────────────┐
4:51:17 PM: │ 1. build.command from netlify.toml │
4:51:17 PM: └────────────────────────────────────┘
4:51:17 PM: ​
4:51:17 PM: $ npm run build
4:51:17 PM: > gatsby-starter-products-with-categories@0.1.0 build /opt/build/repo
4:51:17 PM: > gatsby build
4:51:20 PM: success open and validate gatsby-configs - 0.069s
4:51:20 PM: success load plugins - 0.737s
4:51:20 PM: success onPreInit - 0.010s
4:51:20 PM: success delete html and css files from previous builds - 0.010s
4:51:20 PM: success initialize cache - 0.007s
4:51:20 PM: success copy gatsby files - 0.026s
4:51:20 PM: success onPreBootstrap - 0.006s
4:51:21 PM: success createSchemaCustomization - 0.009s
4:51:21 PM: success source and transform nodes - 0.475s
4:51:21 PM: success building schema - 0.401s
4:51:22 PM: success createPages - 0.072s
4:51:22 PM: success createPagesStatefully - 0.063s
4:51:22 PM: success updating schema - 0.022s
4:51:22 PM: success onPreExtractQueries - 0.000s
4:51:23 PM: success extract queries from components - 1.052s
4:51:23 PM: success write out redirect data - 0.019s
4:51:23 PM: success Build manifest and related icons - 0.105s
4:51:23 PM: success onPostBootstrap - 0.106s
4:51:23 PM: info bootstrap finished - 5.719s
4:51:23 PM: success run static queries - 0.014s - 3/3 221.94/s
4:51:23 PM: success run page queries - 0.208s - 49/49 236.05/s
4:51:23 PM: success write out requires - 0.004s
4:51:57 PM: success Building production JavaScript and CSS bundles - 34.279s
4:51:58 PM: success Rewriting compilation hashes - 0.003s
4:52:04 PM: node
4:52:04 PM: 12.18.0
4:52:04 PM: linux
4:52:05 PM: failed Building static HTML for pages - 6.845s
4:52:05 PM: error Building static HTML failed for path “/”
4:52:05 PM:
4:52:05 PM:
4:52:05 PM: WebpackError: Invariant failed
4:52:05 PM:
4:52:05 PM: - build-html.js:107 doBuildPages
4:52:05 PM: [repo]/[gatsby]/dist/commands/build-html.js:107:24
4:52:05 PM:
4:52:05 PM: - build-html.js:121 async buildHTML
4:52:05 PM: [repo]/[gatsby]/dist/commands/build-html.js:121:3
4:52:05 PM:
4:52:05 PM: - build.js:219 async build
4:52:05 PM: [repo]/[gatsby]/dist/commands/build.js:219:5
4:52:05 PM:
4:52:05 PM:
4:52:05 PM: npm ERR! code ELIFECYCLE
4:52:05 PM: npm ERR! errno 1
4:52:05 PM: npm ERR! gatsby-starter-products-with-categories@0.1.0 build: gatsby build
4:52:05 PM: npm ERR! Exit status 1
4:52:05 PM: npm ERR!
4:52:05 PM: npm ERR! Failed at the gatsby-starter-products-with-categories@0.1.0 build script.
4:52:05 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
4:52:05 PM: npm ERR! A complete log of this run can be found in:
4:52:05 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-07-25T20_52_05_157Z-debug.log
4:52:05 PM: ​
4:52:05 PM: ┌─────────────────────────────┐
4:52:05 PM: │ “build.command” failed │
4:52:05 PM: └─────────────────────────────┘
4:52:05 PM: ​
4:52:05 PM: Error message
4:52:05 PM: Command failed with exit code 1: npm run build
4:52:05 PM: ​
4:52:05 PM: Error location
4:52:05 PM: In build.command from netlify.toml:
4:52:05 PM: npm run build
4:52:05 PM: ​
4:52:05 PM: Resolved config
4:52:05 PM: build:
4:52:05 PM: command: npm run build
4:52:05 PM: commandOrigin: config
4:52:05 PM: environment:
4:52:05 PM: - ALGOLIA_APPLICATION_ID
4:52:05 PM: - ALGOLIA_INDEX
4:52:05 PM: - AlGOLIA_ADMIN_KEY
4:52:05 PM: publish: /opt/build/repo/public
4:52:05 PM: plugins:
4:52:05 PM: - inputs: {}
4:52:05 PM: origin: config
4:52:05 PM: package: ‘@netlify/plugin-local-install-core’
4:52:05 PM: - inputs: {}
4:52:05 PM: origin: config
4:52:05 PM: package: ./plugins/netlify-plugin-algolia-index
4:52:05 PM: Caching artifacts
4:52:05 PM: Started saving node modules
4:52:05 PM: Finished saving node modules
4:52:05 PM: Started saving build plugins
4:52:05 PM: Finished saving build plugins
4:52:05 PM: Started saving yarn cache
4:52:05 PM: Finished saving yarn cache
4:52:05 PM: Started saving pip cache
4:52:05 PM: Finished saving pip cache
4:52:05 PM: Started saving emacs cask dependencies
4:52:05 PM: Finished saving emacs cask dependencies
4:52:05 PM: Started saving maven dependencies
4:52:05 PM: Finished saving maven dependencies
4:52:05 PM: Started saving boot dependencies
4:52:05 PM: Finished saving boot dependencies
4:52:05 PM: Started saving go dependencies
4:52:05 PM: Finished saving go dependencies
4:52:05 PM: Error running command: Build script returned non-zero exit code: 1
4:52:05 PM: Failing build: Failed to build site
4:52:05 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
4:52:05 PM: Finished processing build request in 2m26.775666415s

Hello @cmarabate,

If your site is building locally, I would recommend checking that the versions used on the buildbot matches what you are using locally (i.e. nodejs version, gatsby version, etc.). If it doesn’t, try explicitly setting those versions (some info on how to set the node version here). Hope that helps.