Gatsby deploy failed: Build script returned non-zero exit code: 127

I’ve tried deploying my Gatsby site from Netlify many times with the same error code 127 coming back. The site builds locally, and I get my site running locally with gatsby serve. The error states that the deploy failed during stage ‘building site’.

I have tried nuking and re-installing my node modules as well as clearing cache. I thought it may have something to do with my gatsby-config file, but everything looks okay there.

I’ve built and deployed this site many times before through Netlify, I can’t seem to pinpoint what change I made that would’ve caused it to stop building.

Please feel free to take a look at the repo for this project, GitHub - dillonemorris/ui-gems: Bringing you the best of the best UI designs on the web.. Any help is appreciated, thank you!

10:37:01 AM: Build ready to start
10:37:03 AM: build-image version: 8e315e54bc4032a32e73290be556cde4f8348c12
10:37:03 AM: build-image tag: v2.8.2
10:37:03 AM: buildbot version: b925d11411cabfe7b120501027bd0e96dbc28dde
10:37:04 AM: Fetching cached dependencies
10:37:04 AM: Starting to download cache of 291.0MB
10:37:07 AM: Finished downloading cache in 3.042485338s
10:37:07 AM: Starting to extract cache
10:37:18 AM: Finished extracting cache in 10.957310316s
10:37:18 AM: Finished fetching cache in 14.103516542s
10:37:18 AM: Starting to prepare the repo for build
10:37:18 AM: Preparing Git Reference refs/heads/master
10:37:19 AM: Starting build script
10:37:19 AM: Installing dependencies
10:37:19 AM: Started restoring cached node version
10:37:21 AM: Finished restoring cached node version
10:37:21 AM: v8.16.0 is already installed.
10:37:22 AM: Now using node v8.16.0 (npm v6.4.1)
10:37:22 AM: Attempting ruby version 2.3.6, read from environment
10:37:24 AM: Using ruby version 2.3.6
10:37:24 AM: Using PHP version 5.6
10:37:24 AM: Started restoring cached node modules
10:37:24 AM: Finished restoring cached node modules
10:37:24 AM: Installing NPM modules using NPM version 6.4.1
10:37:51 AM: npm
10:37:51 AM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
10:37:51 AM: npm
10:37:51 AM:  WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:37:51 AM: added 12 packages from 15 contributors, removed 2 packages, updated 13 packages and audited 35601 packages in 25.938s
10:37:51 AM: found 0 vulnerabilities
10:37:51 AM: NPM modules installed
10:37:51 AM: Started restoring cached go cache
10:37:53 AM: Finished restoring cached go cache
10:37:53 AM: Installing Go version 1.10
10:37:53 AM: unset GOOS;
10:37:53 AM: unset GOARCH;
10:37:53 AM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64';
10:37:53 AM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64/bin:${PATH}";
10:37:53 AM: go version >&2;
10:37:53 AM: export GIMME_ENV='/opt/buildhome/.gimme_cache/env/go1.10.linux.amd64.env';
10:37:53 AM: go version go1.10 linux/amd64
10:37:53 AM: Installing missing commands
10:37:53 AM: Verify run directory
10:37:53 AM: Executing user command: gatsby build
10:37:56 AM: success open and validate gatsby-configs — 0.015 s
10:37:57 AM: success load plugins — 1.703 s
10:37:57 AM: success onPreInit — 0.099 s
10:37:58 AM: success delete html and css files from previous builds — 0.010 s
10:37:58 AM: success initialize cache — 0.008 s
10:37:58 AM: success copy gatsby files — 0.025 s
10:37:58 AM: success onPreBootstrap — 0.012 s
10:37:58 AM: Starting to fetch data from Contentful
10:37:58 AM: Fetching default locale
10:37:58 AM: default locale is : en-US
10:37:58 AM: contentTypes fetched 4
10:37:58 AM: Updated entries  101
10:37:58 AM: Deleted entries  0
10:37:58 AM: Updated assets  114
10:37:58 AM: Deleted assets  0
10:37:58 AM: Fetch Contentful data: 690.641ms
10:37:59 AM: success source and transform nodes — 1.109 s
10:37:59 AM: success building schema — 0.410 s
10:37:59 AM: success createPages — 0.178 s
10:37:59 AM: success createPagesStatefully — 0.043 s
10:37:59 AM: success onPreExtractQueries — 0.006 s
10:37:59 AM: success update schema — 0.044 s
10:37:59 AM: warning Using the global `graphql` tag is deprecated, and will not be supported in v3.
10:37:59 AM: Import it instead like:  import { graphql } from 'gatsby' in file:
10:37:59 AM: /opt/build/repo/src/templates/index.js
10:37:59 AM: success extract queries from components — 0.145 s
10:37:59 AM: success run static queries — 0.001 s
10:38:02 AM: success run page queries — 2.915 s — 110/110 37.75 queries/second
10:38:02 AM: success write out page data — 0.005 s
10:38:02 AM: success write out redirect data — 0.001 s
10:38:02 AM: node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZN4vips6VImage11premultiplyEPNS_7VOptionE
10:38:02 AM: node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZN4vips6VImage11premultiplyEPNS_7VOptionE
10:38:02 AM: node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZN4vips6VImage11premultiplyEPNS_7VOptionE
10:38:02 AM: Skipping functions preparation step: no functions directory set
10:38:02 AM: Caching artifacts
10:38:02 AM: Started saving node modules
10:38:02 AM: Finished saving node modules
10:38:02 AM: Started saving pip cache
10:38:03 AM: Finished saving pip cache
10:38:03 AM: Started saving emacs cask dependencies
10:38:03 AM: Finished saving emacs cask dependencies
10:38:03 AM: Started saving maven dependencies
10:38:03 AM: Finished saving maven dependencies
10:38:03 AM: Started saving boot dependencies
10:38:03 AM: Finished saving boot dependencies
10:38:03 AM: Started saving go dependencies
10:38:05 AM: Finished saving go dependencies
10:38:05 AM: Error running command: Build script returned non-zero exit code: 127
10:38:05 AM: Failing build: Failed to build site
10:38:05 AM: failed during stage 'building site': Build script returned non-zero exit code: 127
10:38:05 AM: Finished processing build request in 1m1.47415387s

hi there, have you used the forum search (try 127) :slight_smile: ? there are a number of people who have already encountered this issue. Usually it is either related to incorrect build commands depending on the SSG you are using or there being an issue with your package.json.

Give this a read through:

If you still can’t make it work, please summarize what you’ve tried, which results you had, any changes, your netlify instance name etc. Also a screenshot of your build settings would be useful.

I found this searching the build error I was seeing:

node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZNK4vips6VImage7pngsaveEPcPNS_7VOptionE

Full build log

In my case I think it was a mismatch between the Gatsby version ^2.13.39 and attempted bump to gatsby-plugin-sharp from ^2.2.9 to 2.2.18 in this automated PR from Dependabot. Upgrading all packages to latest exact versions with yarn upgrade -L --exact did the trick, but I expect just bumping Gatsby to ^2.14.0 would also have worked.

As to why I used --exact, I like pinning deps and automating dependency updates.
Had to post this link in a separate post because since I am new I am only allowed a max of 2 links per post :frowning:

hey ricky, the limit on links is only for new users. If you post a couple more times that restriction will be automatically lifted. :+1: