Deployment Failed - Error Generating JavaScript bundles failed

I have been trying to deploy a Gatsby application but the deployment keeps failing whilst trying to generate the JavaScript bundles. I get multiple errors about being unable to resolve files within my components folder.

The application builds fine and also runs locally without any pathing errors.

Netlify Site Name - brave-pasteur-a4d319 (Netlify App)
Github Repo - GitHub - JackBPainter/portfolio-v2: This is my second portfolio built using Gatsby.js

Full Deploy Log
5:24:05 PM: Build ready to start
5:24:07 PM: build-image version: 30f629161c0736b1a3ecd8b418e5eeffab5c0faf
5:24:07 PM: build-image tag: v3.3.14
5:24:07 PM: buildbot version: 80440c4491d323247b9d55f7bea2ea6bc96ce8d2
5:24:08 PM: Fetching cached dependencies
5:24:08 PM: Failed to fetch cache, continuing with build
5:24:08 PM: Starting to prepare the repo for build
5:24:08 PM: No cached dependencies found. Cloning fresh repo
5:24:08 PM: git clone GitHub - JackBPainter/portfolio-v2: This is my second portfolio built using Gatsby.js
5:24:09 PM: Preparing Git Reference refs/heads/master
5:24:10 PM: Starting build script
5:24:10 PM: Installing dependencies
5:24:11 PM: v10.20.1 is already installed.
5:24:12 PM: Now using node v10.20.1 (npm v6.14.4)
5:24:12 PM: Started restoring cached build plugins
5:24:12 PM: Finished restoring cached build plugins
5:24:12 PM: Attempting ruby version 2.6.2, read from environment
5:24:13 PM: Using ruby version 2.6.2
5:24:14 PM: Using PHP version 5.6
5:24:14 PM: 5.2 is already installed.
5:24:14 PM: Using Swift version 5.2
5:24:14 PM: Started restoring cached node modules
5:24:14 PM: Finished restoring cached node modules
5:24:14 PM: Installing NPM modules using NPM version 6.14.4
5:24:59 PM: > sharp@0.25.3 install /opt/build/repo/node_modules/sharp
5:24:59 PM: > (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
5:25:00 PM: info
5:25:00 PM: sharp
5:25:00 PM: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz
5:25:02 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/bmp/node_modules/core-js
5:25:02 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:02 PM: Thank you for using core-js ( GitHub - zloirock/core-js: Standard Library ) for polyfilling JavaScript standard library!
5:25:02 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
5:25:02 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/core/node_modules/core-js
5:25:02 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:02 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/custom/node_modules/core-js
5:25:02 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:02 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/gif/node_modules/core-js
5:25:02 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/jpeg/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-blit/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-blur/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-circle/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-color/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-contain/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-cover/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:03 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-crop/node_modules/core-js
5:25:03 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-displace/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-dither/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-fisheye/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-flip/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-gaussian/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-invert/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-mask/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-normalize/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:04 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-print/node_modules/core-js
5:25:04 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-resize/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-rotate/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-scale/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-shadow/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugin-threshold/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/plugins/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/png/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/tiff/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:05 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/types/node_modules/core-js
5:25:05 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:06 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@jimp/utils/node_modules/core-js
5:25:06 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:06 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/core-js
5:25:06 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:06 PM: > core-js-pure@3.6.5 postinstall /opt/build/repo/node_modules/core-js-pure
5:25:06 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:06 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/jimp/node_modules/core-js
5:25:06 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
5:25:06 PM: > gatsby-telemetry@1.3.9 postinstall /opt/build/repo/node_modules/gatsby-telemetry
5:25:06 PM: > node src/postinstall.js || true
5:25:07 PM: > cwebp-bin@5.1.0 postinstall /opt/build/repo/node_modules/cwebp-bin
5:25:07 PM: > node lib/install.js
5:25:07 PM: :heavy_check_mark: cwebp pre-build test passed successfully
5:25:07 PM: > mozjpeg@6.0.1 postinstall /opt/build/repo/node_modules/mozjpeg
5:25:07 PM: > node lib/install.js
5:25:08 PM: :heavy_check_mark: mozjpeg pre-build test passed successfully
5:25:08 PM: > pngquant-bin@5.0.2 postinstall /opt/build/repo/node_modules/pngquant-bin
5:25:08 PM: > node lib/install.js
5:25:08 PM: :heavy_check_mark: pngquant pre-build test passed successfully
5:25:08 PM: > gatsby-cli@2.12.34 postinstall /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli
5:25:08 PM: > node scripts/postinstall.js
5:25:08 PM: > gatsby@2.22.9 postinstall /opt/build/repo/node_modules/gatsby
5:25:08 PM: > node scripts/postinstall.js
5:25:12 PM: npm
5:25:12 PM: WARN
5:25:12 PM: optional
5:25:12 PM: SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
5:25:12 PM: npm
5:25:12 PM: WARN
5:25:12 PM: notsup
5:25:12 PM: SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
5:25:12 PM: npm
5:25:12 PM: WARN
5:25:12 PM: optional
5:25:12 PM: SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
5:25:12 PM: npm
5:25:12 PM: WARN
5:25:12 PM: notsup
5:25:12 PM: SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
5:25:12 PM: added 2337 packages from 1260 contributors and audited 2345 packages in 56.696s
5:25:14 PM: 154 packages are looking for funding
5:25:14 PM: run npm fund for details
5:25:14 PM: found 0 vulnerabilities
5:25:14 PM: NPM modules installed
5:25:14 PM: Started restoring cached go cache
5:25:14 PM: Finished restoring cached go cache
5:25:14 PM: go version go1.12 linux/amd64
5:25:14 PM: go version go1.12 linux/amd64
5:25:14 PM: Installing missing commands
5:25:14 PM: Verify run directory
5:25:14 PM: Executing user command: gatsby build
5:25:17 PM: success open and validate gatsby-configs - 0.038s
5:25:18 PM: success load plugins - 1.300s
5:25:18 PM: success onPreInit - 0.016s
5:25:18 PM: success delete html and css files from previous builds - 0.021s
5:25:18 PM: success initialize cache - 0.087s
5:25:18 PM: success copy gatsby files - 0.036s
5:25:18 PM: success onPreBootstrap - 0.008s
5:25:19 PM: success createSchemaCustomization - 0.008s
5:25:19 PM: success source and transform nodes - 0.142s
5:25:19 PM: success building schema - 0.386s
5:25:19 PM: success createPages - 0.001s
5:25:19 PM: success createPagesStatefully - 0.101s
5:25:19 PM: success onPreExtractQueries - 0.000s
5:25:19 PM: success update schema - 0.030s
5:25:19 PM: warning Using the global graphql tag is deprecated, and will not be supported in v3.
5:25:19 PM: Import it instead like: import { graphql } from ‘gatsby’ in file:
5:25:19 PM: /opt/build/repo/src/pages/projects.js
5:25:20 PM: success extract queries from components - 0.404s
5:25:20 PM: success write out requires - 0.005s
5:25:20 PM: success write out redirect data - 0.001s
5:25:20 PM: success Build manifest and related icons - 0.079s
5:25:20 PM: success onPostBootstrap - 0.081s
5:25:20 PM: ⠀
5:25:20 PM: info bootstrap finished - 5.317s
5:25:20 PM: ⠀
5:25:34 PM: failed Building production JavaScript and CSS bundles - 14.251s
5:25:34 PM: error Generating JavaScript bundles failed
5:25:34 PM: Can’t resolve ‘…/components/Layout’ in ‘/opt/build/repo/src/pages’
5:25:34 PM: If you’re trying to use a package make sure that ‘…/components/Layout’ is installed. If you’re trying to use a local file make sure that the path is correct.
5:25:34 PM: error Generating JavaScript bundles failed
5:25:34 PM: Can’t resolve ‘…/components/Layout’ in ‘/opt/build/repo/src/pages’
5:25:34 PM: If you’re trying to use a package make sure that ‘…/components/Layout’ is installed. If you’re trying to use a local file make sure that the path is correct.
5:25:34 PM: error Generating JavaScript bundles failed
5:25:34 PM: Can’t resolve ‘…/components/Layout’ in ‘/opt/build/repo/src/pages’
5:25:34 PM: If you’re trying to use a package make sure that ‘…/components/Layout’ is installed. If you’re trying to use a local file make sure that the path is correct.
5:25:34 PM: error Generating JavaScript bundles failed
5:25:34 PM: Can’t resolve ‘…/components/Layout’ in ‘/opt/build/repo/src/pages’
5:25:34 PM: If you’re trying to use a package make sure that ‘…/components/Layout’ is installed. If you’re trying to use a local file make sure that the path is correct.
5:25:34 PM: error Generating JavaScript bundles failed
5:25:34 PM: Can’t resolve ‘…/components/Layout’ in ‘/opt/build/repo/src/pages’
5:25:34 PM: If you’re trying to use a package make sure that ‘…/components/Layout’ is installed. If you’re trying to use a local file make sure that the path is correct.
5:25:34 PM: error Generating JavaScript bundles failed
5:25:34 PM: Can’t resolve ‘…/components/Skills’ in ‘/opt/build/repo/src/pages’
5:25:34 PM: If you’re trying to use a package make sure that ‘…/components/Skills’ is installed. If you’re trying to use a local file make sure that the path is correct.
5:25:34 PM: not finished run queries - 14.740s
5:25:34 PM: not finished Generating image thumbnails - 14.704s
5:25:34 PM: Skipping functions preparation step: no functions directory set
5:25:34 PM: Caching artifacts
5:25:34 PM: Started saving node modules
5:25:34 PM: Finished saving node modules
5:25:34 PM: Started saving build plugins
5:25:35 PM: Finished saving build plugins
5:25:35 PM: Started saving pip cache
5:25:41 PM: Finished saving pip cache
5:25:41 PM: Started saving emacs cask dependencies
5:25:41 PM: Finished saving emacs cask dependencies
5:25:41 PM: Started saving maven dependencies
5:25:41 PM: Finished saving maven dependencies
5:25:41 PM: Started saving boot dependencies
5:25:41 PM: Finished saving boot dependencies
5:25:41 PM: Started saving go dependencies
5:25:41 PM: Finished saving go dependencies
5:25:44 PM: Error running command: Build script returned non-zero exit code: 1
5:25:44 PM: Failing build: Failed to build site
5:25:44 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
5:25:44 PM: Finished processing build request in 1m36.512207859s

Hey there, thanks for reaching out.

What you are describing sounds a bit like a an issue with case sensitivity on our system.

Can you give this a read through and let us know if that fixes the issue?

Hey Perry, that was the exact problem. Thanks for saving me another day of frustration!

1 Like

Hey Perry
I had the same problem and for the time being solved it by removing the offending script function. But how do I know which part is wrong in terms of the case?

This is my commented out code that was causing the issue…
// export const onClientEntry = () => {
// // IntersectionObserver polyfill for gatsby-background-image (Safari, IE)
// if (!(IntersectionObserver in window)) {
// import(intersection-observer)
// console.log(# IntersectionObserver is polyfilled!)
// }
// }
And this is the error;

error Generating JavaScript bundles failed
Can’t resolve ‘intersection-observer’ in ‘/opt/build/repo’

It looks like it’s having a problem importing the script.

Hey @stevej

If you are seeing this error while building/deploying, it is because of the reference to window which is not available until a script is executed in the browser. Without seeing this portion of script in context it is difficult to help troubleshoot. Are you able to share the repository?