Failed during stage 'building site': Build script returned non-zero exit code: 7

Hi folks - I keep running into this issue when deploying my site. I’m using Gatsby, and everything seems to be working fine on my end.

12:27:25 PM: Build ready to start
12:27:26 PM: build-image version: 8e315e54bc4032a32e73290be556cde4f8348c12
12:27:26 PM: build-image tag: v2.8.2
12:27:26 PM: buildbot version: 45cd00068410d70db72c9672cdd014995488e12a
12:27:26 PM: No cache source specified, skip fetching cache
12:27:26 PM: Starting to prepare the repo for build
12:27:27 PM: No cached dependencies found. Cloning fresh repo
12:27:27 PM: git clone https ://github .com/jherrc/website
12:27:30 PM: Preparing Git Reference refs/heads/master
12:27:31 PM: Starting build script
12:27:31 PM: Installing dependencies
12:27:32 PM: Downloading and installing node v8.17.0…
12:27:32 PM: Downloading https: //nodejs .org/dist/v8.17.0/node-v8.17.0-linux-x64.tar.xz…
12:27:32 PM:
#################
12:27:32 PM: 23.7%
12:27:32 PM:
######################################
12:27:32 PM: ################################## 100.0%
12:27:32 PM: Computing checksum with sha256sum
12:27:32 PM: Checksums matched!
12:27:34 PM: Now using node v8.17.0 (npm v6.13.4)
12:27:35 PM: Attempting ruby version 2.3.6, read from environment
12:27:36 PM: Using ruby version 2.3.6
12:27:36 PM: Using PHP version 5.6
12:27:36 PM: Started restoring cached node modules
12:27:36 PM: Finished restoring cached node modules
12:27:37 PM: Installing NPM modules using NPM version 6.13.4
12:28:27 PM: > bufferutil@4.0.2 install /opt/build/repo/node_modules/bufferutil
12:28:27 PM: > node-gyp-build
12:28:28 PM: > utf-8-validate@5.0.3 install /opt/build/repo/node_modules/utf-8-validate
12:28:28 PM: > node-gyp-build
12:28:28 PM: > sharp@0.25.4 install /opt/build/repo/node_modules/sharp
12:28:28 PM: > (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
12:28:28 PM: info
12:28:28 PM: sharp Downloading https:// github. com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz
12:28:31 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
12:28:31 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
12:28:31 PM: Thank you for using core-js ( https ://github .com/zloirock/core-js ) for polyfilling JavaScript standard library!
12:28:31 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
12:28:31 PM: > https ://opencollective .com/core-js
12:28:31 PM: > https:// www.patreon. com/zloirock
12:28:31 PM: Also, the author of core-js ( https:// github. com/zloirock ) is looking for a good job -)
12:28:31 PM: > core-js@3.7.0 postinstall /opt/build/repo/node_modules/core-js
12:28:31 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
12:28:31 PM: > core-js-pure@3.7.0 postinstall /opt/build/repo/node_modules/core-js-pure
12:28:31 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
12:28:32 PM: > gatsby-telemetry@1.4.0 postinstall /opt/build/repo/node_modules/gatsby-telemetry
12:28:32 PM: > node src/postinstall.js || true
12:28:32 PM: > mozjpeg@7.0.0 postinstall /opt/build/repo/node_modules/mozjpeg
12:28:32 PM: > node lib/install.js
12:28:32 PM: :heavy_check_mark: mozjpeg pre-build test passed successfully
12:28:32 PM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/node_modules/pngquant-bin
12:28:32 PM: > node lib/install.js
12:28:33 PM: :heavy_check_mark: pngquant pre-build test passed successfully
12:28:33 PM: > gatsby-cli@2.13.0 postinstall /opt/build/repo/node_modules/gatsby-cli
12:28:33 PM: > node scripts/postinstall.js
12:28:33 PM: > gatsby@2.26.0 postinstall /opt/build/repo/node_modules/gatsby
12:28:33 PM: > node scripts/postinstall.js
12:28:37 PM: npm WARN
12:28:37 PM: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
12:28:37 PM: npm
12:28:37 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
12:28:37 PM: npm WARN optional
12:28:37 PM: SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
12:28:37 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
12:28:37 PM: added 2222 packages from 1264 contributors and audited 2231 packages in 59.632s
12:28:40 PM: 137 packages are looking for funding
12:28:40 PM: run npm fund for details
12:28:40 PM: found 0 vulnerabilities
12:28:40 PM: NPM modules installed
12:28:41 PM: Started restoring cached go cache
12:28:41 PM: Finished restoring cached go cache
12:28:41 PM: Installing Go version 1.10
12:28:46 PM: unset GOOS;
12:28:46 PM: unset GOARCH;
12:28:46 PM: export GOROOT=‘/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64’;
12:28:46 PM: export PATH=“/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64/bin:${PATH}”;
12:28:46 PM: go version >&2;
12:28:46 PM: export GIMME_ENV=“/opt/buildhome/.gimme_cache/env/go1.10.linux.amd64.env”
12:28:46 PM: go version go1.10 linux/amd64
12:28:46 PM: Installing missing commands
12:28:46 PM: Verify run directory
12:28:46 PM: Executing user command: gatsby build
12:28:47 PM: /opt/build/repo/node_modules/gatsby-cli/lib/init-starter.js:104
12:28:47 PM: } catch {
12:28:47 PM: ^
12:28:47 PM: SyntaxError: Unexpected token {
12:28:47 PM: at createScript (vm.js:80:10)
12:28:47 PM: at Object.runInThisContext (vm.js:139:10)
12:28:47 PM: at Module._compile (module.js:617:28)
12:28:47 PM: at Object.Module._extensions…js (module.js:664:10)
12:28:47 PM: at Module.load (module.js:566:32)
12:28:47 PM: at tryModuleLoad (module.js:506:12)
12:28:47 PM: at Function.Module._load (module.js:498:3)
12:28:47 PM: at Module.require (module.js:597:17)
12:28:47 PM: at require (internal/module.js:11:18)
12:28:47 PM: at Object. (/opt/build/repo/node_modules/gatsby-cli/lib/create-cli.js:28:20)
12:28:47 PM: Skipping functions preparation step: no functions directory set
12:28:47 PM: Caching artifacts
12:28:47 PM: Started saving node modules
12:28:47 PM: Finished saving node modules
12:28:47 PM: Started saving pip cache
12:28:47 PM: Finished saving pip cache
12:28:47 PM: Started saving emacs cask dependencies
12:28:47 PM: Finished saving emacs cask dependencies
12:28:47 PM: Started saving maven dependencies
12:28:47 PM: Finished saving maven dependencies
12:28:47 PM: Started saving boot dependencies
12:28:47 PM: Finished saving boot dependencies
12:28:47 PM: Started saving go dependencies
12:28:49 PM: Finished saving go dependencies
12:28:52 PM: Error running command: Build script returned non-zero exit code: 7
12:28:52 PM: Failing build: Failed to build site
12:28:52 PM: failed during stage ‘building site’: Build script returned non-zero exit code: 7
12:28:52 PM: Finished processing build request in 1m25.840102269s

Sorry, I had to separate the links in the log due to my newbie account limitations.
I found this older post with somebody who also got exit code 7, but the issue seems different to mine (plus I don’t have any environment variables set up)… so any leads would be appreciated! Do let me know if I need to provide any additional information.

Thanks in advance!

The problem is mostly that you’re using Node 8 and Gatsby needs Node 10 something (minimum). Remove that from your package.json and try.

That did the trick! I couldn’t really find anything pointing to Node 8 in my package.json file, but for now a good solution was to add NODE_VERSION 10 as a variable in Netlify - the opposite as the post I found. And then deployment went through. Thank you!

1 Like