Gatsby: failed during stage 'building site': Build script returned non-zero exit code: 127

Created on 9 Jun 2019  Β·  19Comments  Β·  Source: gatsbyjs/gatsby

I'm new to both Gatsby and Netlify, any help would be appreciated. The site deploys perfectly on localhost but throws an error on Netlify.

2:35:34 PM: Build ready to start
2:35:35 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
2:35:35 PM: build-image tag: v3.3.2
2:35:35 PM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045
2:35:36 PM: Fetching cached dependencies
2:35:36 PM: Starting to download cache of 255.0KB
2:35:36 PM: Finished downloading cache in 133.65249ms
2:35:36 PM: Starting to extract cache
2:35:36 PM: Failed to fetch cache, continuing with build
2:35:36 PM: Starting to prepare the repo for build
2:35:36 PM: No cached dependencies found. Cloning fresh repo
2:35:36 PM: git clone https://github.com/niphadkarneha/site
2:35:37 PM: Preparing Git Reference refs/heads/master
2:35:37 PM: Starting build script
2:35:37 PM: Installing dependencies
2:35:39 PM: Downloading and installing node v10.16.0...
2:35:39 PM: Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz...
2:35:39 PM:

#

2:35:39 PM: 24.3%
2:35:39 PM:

#

2:35:39 PM: ############# 90.6%
2:35:39 PM:

#

2:35:39 PM: ############################ 100.0%
2:35:39 PM: Computing checksum with sha256sum
2:35:40 PM: Checksums matched!
2:35:42 PM: Now using node v10.16.0 (npm v6.9.0)
2:35:42 PM: Attempting ruby version 2.6.2, read from environment
2:35:44 PM: Using ruby version 2.6.2
2:35:44 PM: Using PHP version 5.6
2:35:44 PM: Started restoring cached node modules
2:35:44 PM: Finished restoring cached node modules
2:35:44 PM: Installing NPM modules using NPM version 6.9.0
2:36:16 PM: > [email protected] install /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp
2:36:16 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
2:36:17 PM: info
2:36:17 PM: sharp
2:36:17 PM: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
2:36:19 PM: > [email protected] install /opt/build/repo/node_modules/sharp
2:36:19 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
2:36:19 PM: info
2:36:19 PM: sharp Detected globally-installed libvips v8.6.2
2:36:19 PM: info
2:36:19 PM: sharp Building from source via node-gyp
2:36:22 PM: make: Entering directory '/opt/build/repo/node_modules/sharp/build'
2:36:22 PM: TOUCH Release/obj.target/libvips-cpp.stamp
2:36:22 PM: CXX(target) Release/obj.target/sharp/src/common.o
2:36:25 PM: CXX(target) Release/obj.target/sharp/src/metadata.o
2:36:26 PM: CXX(target) Release/obj.target/sharp/src/stats.o
2:36:28 PM: CXX(target) Release/obj.target/sharp/src/operations.o
2:36:30 PM: CXX(target) Release/obj.target/sharp/src/pipeline.o
2:36:33 PM: CXX(target) Release/obj.target/sharp/src/sharp.o
2:36:35 PM: CXX(target) Release/obj.target/sharp/src/utilities.o
2:36:36 PM: SOLINK_MODULE(target) Release/obj.target/sharp.node
2:36:36 PM: COPY Release/sharp.node
2:36:37 PM: make: Leaving directory '/opt/build/repo/node_modules/sharp/build'
2:36:37 PM: > [email protected] postinstall /opt/build/repo/node_modules/@babel/polyfill/node_modules/core-js
2:36:37 PM: > node scripts/postinstall || echo "ignore"
2:36:37 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
2:36:37 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
2:36:37 PM: > https://opencollective.com/core-js
2:36:37 PM: > https://www.patreon.com/zloirock
2:36:37 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
2:36:37 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js-pure
2:36:37 PM: > node scripts/postinstall || echo "ignore"
2:36:37 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
2:36:37 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
2:36:37 PM: > https://opencollective.com/core-js
2:36:37 PM: > https://www.patreon.com/zloirock
2:36:37 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
2:36:37 PM: > [email protected] postinstall /opt/build/repo/node_modules/gatsby-telemetry
2:36:37 PM: > node src/postinstall.js
2:36:38 PM: > [email protected] postinstall /opt/build/repo/node_modules/cwebp-bin
2:36:38 PM: > node lib/install.js
2:36:38 PM: βœ” cwebp pre-build test passed successfully
2:36:38 PM: > [email protected] postinstall /opt/build/repo/node_modules/mozjpeg
2:36:38 PM: > node lib/install.js
2:36:38 PM: βœ” mozjpeg pre-build test passed successfully
2:36:38 PM: > [email protected] postinstall /opt/build/repo/node_modules/pngquant-bin
2:36:38 PM: > node lib/install.js
2:36:39 PM: βœ” pngquant pre-build test passed successfully
2:36:41 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
2:36:41 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:36:41 PM: npm WARN
2:36:41 PM: optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
2:36:41 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:36:41 PM: added 1996 packages from 1040 contributors and audited 26919 packages in 56.012s
2:36:41 PM: found 0 vulnerabilities
2:36:41 PM: NPM modules installed
2:36:42 PM: Started restoring cached go cache
2:36:42 PM: Finished restoring cached go cache
2:36:42 PM: unset GOOS;
2:36:42 PM: unset GOARCH;
2:36:42 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
2:36:42 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
2:36:42 PM: go version >&2;
2:36:42 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
2:36:42 PM: go version go1.12 linux/amd64
2:36:42 PM: Installing missing commands
2:36:42 PM: Verify run directory
2:36:42 PM: Executing user command: gatsby build
2:36:44 PM: success open and validate gatsby-configs β€” 0.014 s
2:36:45 PM: success load plugins β€” 0.967 s
2:36:45 PM: success onPreInit β€” 0.006 s
2:36:45 PM: success delete html and css files from previous builds β€” 0.006 s
2:36:45 PM: success initialize cache β€” 0.007 s
2:36:45 PM: success copy gatsby files β€” 0.021 s
2:36:45 PM: success onPreBootstrap β€” 0.009 s
2:36:45 PM: success source and transform nodes β€” 0.091 s
2:36:45 PM: success building schema β€” 0.256 s
2:36:45 PM: success createPages β€” 0.047 s
2:36:45 PM: success createPagesStatefully β€” 0.032 s
2:36:45 PM: success onPreExtractQueries β€” 0.001 s
2:36:46 PM: success update schema β€” 0.042 s
2:36:46 PM: success extract queries from components β€” 0.074 s
2:36:46 PM: success run static queries β€” 0.001 s
2:36:46 PM: success run page queries β€” 0.265 s β€” 9/9 33.98 queries/second
2:36:46 PM: success write out page data β€” 0.003 s
2:36:46 PM: success write out redirect data β€” 0.001 s
2:36:46 PM: node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZN4vips6VImage11premultiplyEPNS_7VOptionE
2:36:46 PM: Skipping functions preparation step: no functions directory set
2:36:46 PM: Caching artifacts
2:36:46 PM: Started saving node modules
2:36:46 PM: Finished saving node modules
2:36:46 PM: Started saving pip cache
2:36:46 PM: Finished saving pip cache
2:36:46 PM: Started saving emacs cask dependencies
2:36:46 PM: Finished saving emacs cask dependencies
2:36:46 PM: Started saving maven dependencies
2:36:46 PM: Finished saving maven dependencies
2:36:46 PM: Started saving boot dependencies
2:36:46 PM: Finished saving boot dependencies
2:36:46 PM: Started saving go dependencies
2:36:46 PM: Finished saving go dependencies
2:36:48 PM: Error running command: Build script returned non-zero exit code: 127
2:36:48 PM: Failing build: Failed to build site
2:36:48 PM: failed during stage 'building site': Build script returned non-zero exit code: 127
2:36:48 PM: Finished processing build request in 1m13.192242775s
2:36:49 PM: Shutting down logging, 0 messages pending

question or discussion

Most helpful comment

This feels silly - it was a yarn.lock file in my repo that was causing the issue. I've been using npm and Netlify did not take well to having both the yarn.lock file and package-lock.json. Not sure how it got there, but once the file was deleted problem was solved.

All 19 comments

Hi @niphadkarneha!

Sorry to hear you are having an issue. This might be a problem with sharp version and the particular node version that is used at netlify. What version of node do you use with your local builds?

It would also be super helpful if you could share the code with us so that we can test it locally ourselves.

Thanks! :purple_heart:

Hello,

I agree, I recently updated the software on my macbook and these issues got exponentially worse.

Code is available on : https://github.com/niphadkarneha/site

Kind Regards
Neha Niphadkar

@niphadkarneha Thank you! Have you tried clearing netlify cache? Sometimes this helps with their builder. I'll take a deeper look at it if it doesn't help.

/opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZN4vips6VImage11premultiplyEPNS_7VOptionE

Never seen this before but looks like a flaky installation of sharp on Netlify. Keeping an eye out if this happens again.

@freiksenet Yes, I cleared the cache and deployed again. It fails to deploy. I'm going to retrace my steps from the last successful build in order to debug.

Sorry to re-open an issue, but I'm having a similar problem and I have no clue what to do about it after much searching. Would love some help with this! Code can be found here: https://github.com/stufinn/SLMHA

Thank you!

And here's the Netlify Deploy Log:

12:53:07 PM: Build ready to start
12:53:09 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
12:53:09 PM: build-image tag: v3.3.2
12:53:09 PM: buildbot version: ef8d0929ed0baabafd8bbb7d0b021e1fc24180c0
12:53:09 PM: Fetching cached dependencies
12:53:10 PM: Starting to download cache of 233.2MB
12:53:11 PM: Finished downloading cache in 1.975743263s
12:53:11 PM: Starting to extract cache
12:53:20 PM: Finished extracting cache in 8.940013276s
12:53:21 PM: Finished fetching cache in 11.069710111s
12:53:21 PM: Starting to prepare the repo for build
12:53:21 PM: Preparing Git Reference refs/heads/master
12:53:22 PM: Starting build script
12:53:22 PM: Installing dependencies
12:53:23 PM: Started restoring cached node version
12:53:28 PM: Finished restoring cached node version
12:53:29 PM: v10.16.3 is already installed.
12:53:30 PM: Now using node v10.16.3 (npm v6.9.0)
12:53:30 PM: Attempting ruby version 2.6.2, read from environment
12:53:32 PM: Using ruby version 2.6.2
12:53:32 PM: Using PHP version 5.6
12:53:32 PM: Started restoring cached node modules
12:53:32 PM: Finished restoring cached node modules
12:53:32 PM: Started restoring cached yarn cache
12:53:32 PM: Finished restoring cached yarn cache
12:53:33 PM: Installing NPM modules using Yarn version 1.13.0
12:53:34 PM: yarn install v1.13.0
12:53:34 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
12:53:34 PM: [1/4] Resolving packages...
12:53:35 PM: [2/4] Fetching packages...
12:54:06 PM: info [email protected]: The platform "linux" is incompatible with this module.
12:54:06 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
12:54:06 PM: [3/4] Linking dependencies...
12:54:06 PM: warning "gatsby-plugin-sass > [email protected]" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
12:54:24 PM: [4/4] Building fresh packages...
12:54:30 PM: Done in 56.30s.
12:54:30 PM: NPM modules installed using Yarn
12:54:31 PM: Started restoring cached go cache
12:54:31 PM: Finished restoring cached go cache
12:54:31 PM: unset GOOS;
12:54:31 PM: unset GOARCH;
12:54:31 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
12:54:31 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
12:54:31 PM: go version >&2;
12:54:31 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
12:54:31 PM: go version go1.12 linux/amd64
12:54:31 PM: Installing missing commands
12:54:31 PM: Verify run directory
12:54:31 PM: Executing user command: gatsby build
12:54:34 PM: success open and validate gatsby-configs β€” 0.009 s
12:54:36 PM: success load plugins β€” 1.921 s
12:54:36 PM: success onPreInit β€” 0.019 s
12:54:36 PM: success delete html and css files from previous builds β€” 0.008 s
12:54:36 PM: success initialize cache β€” 0.014 s
12:54:36 PM: success copy gatsby files β€” 0.031 s
12:54:37 PM: success onPreBootstrap β€” 0.436 s
12:54:37 PM: Starting to fetch data from Contentful
12:54:37 PM: Fetching default locale
12:54:37 PM: default locale is : en-US
12:54:37 PM: contentTypes fetched 6
12:54:37 PM: Updated entries 28
12:54:37 PM: Deleted entries 0
12:54:37 PM: Updated assets 41
12:54:37 PM: Deleted assets 0
12:54:37 PM: Fetch Contentful data: 272.048ms
12:54:37 PM: success source and transform nodes β€” 0.548 s
12:54:38 PM: success building schema β€” 0.565 s
12:54:38 PM: success createPages β€” 0.074 s
12:54:38 PM: success createPagesStatefully β€” 0.055 s
12:54:38 PM: success onPreExtractQueries β€” 0.008 s
12:54:38 PM: success update schema β€” 0.029 s
12:54:38 PM: success extract queries from components β€” 0.317 s
12:54:40 PM: success run static queries β€” 1.786 s β€” 6/6 3.36 queries/second
12:54:45 PM: success run page queries β€” 4.245 s β€” 20/20 4.71 queries/second
12:54:45 PM: success write out page data β€” 0.005 s
12:54:45 PM: success write out redirect data β€” 0.001 s
12:54:45 PM: node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZNK4vips6VImage7pngsaveEPcPNS_7VOptionE
12:54:45 PM: Skipping functions preparation step: no functions directory set
12:54:45 PM: Caching artifacts
12:54:45 PM: Started saving node modules
12:54:45 PM: Finished saving node modules
12:54:45 PM: Started saving yarn cache
12:54:45 PM: Finished saving yarn cache
12:54:45 PM: Started saving pip cache
12:54:45 PM: Finished saving pip cache
12:54:45 PM: Started saving emacs cask dependencies
12:54:45 PM: Finished saving emacs cask dependencies
12:54:45 PM: Started saving maven dependencies
12:54:45 PM: Finished saving maven dependencies
12:54:45 PM: Started saving boot dependencies
12:54:45 PM: Finished saving boot dependencies
12:54:45 PM: failed during stage 'building site': Build script returned non-zero exit code: 127
12:54:45 PM: Started saving go dependencies
12:54:45 PM: Finished saving go dependencies
12:54:45 PM: Error running command: Build script returned non-zero exit code: 127
12:54:45 PM: Failing build: Failed to build site
12:54:45 PM: Finished processing build request in 1m35.868615847s

This feels silly - it was a yarn.lock file in my repo that was causing the issue. I've been using npm and Netlify did not take well to having both the yarn.lock file and package-lock.json. Not sure how it got there, but once the file was deleted problem was solved.

@freiksenet Yes, I cleared the cache and deployed again. It fails to deploy. I'm going to retrace my steps from the last successful build in order to debug.

did you happen to find out why it was failing? I am having the same issue... :(

@Madgeniusblink, did you see the solution that worked for me last week? Maybe it's a conflict between npm and yarn for you too? This link may help too: https://community.netlify.com/t/error-running-command-build-script-returned-non-zero-exit-code-127/1851/2

I did try deleting the package-lock file but it didn't work :( @stufinn

I did try deleting the package-lock file but it didn't work :( @stufinn

That didn't work for me either, but deleting the yarn.lock file did. May not be the solution but worth a shot. I also deleted the cache and did a fresh npm install to generate a new package-lock.json file for good measure.

I got! @stufinn I am not sure if it was because I downgraded my sharp plugin version or because I also deleted the package-lock file...but now it seems to be working! :)

I had a similar issue; the issue turned out to be using Yarn for building due to having defined it inside netlify.toml, I simply changed that call to use NPM along with other calls in my package.json

I have deleted my package.json and it worked automaticly. I am so happy :-)

I had a similar issue; the issue turned out to be using Yarn for building due to having defined it inside netlify.toml, I simply changed that call to use NPM along with other calls in my package.json

I changed mine to gatsby build and solved the issue :)

I have deleted my package.json and it worked automaticly. I am so happy :-)

If you delete package.json how will it know what to install? I am also experiencing this

@geocine I assume that it should have read β€œpackage-lock.json”

Same here, tried all the methods above. The build only started crashing this morning.
10:28:25 AM: npm ERR! code ELIFECYCLE 10:28:25 AM: npm ERR! errno 1 10:28:25 AM: npm ERR! [email protected] build:app:react-scripts build 10:28:25 AM: npm ERR! Exit status 1 10:28:25 AM: npm ERR! 10:28:25 AM: npm ERR! Failed at the [email protected] build:app script. 10:28:25 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 10:28:25 AM: npm ERR! A complete log of this run can be found in: 10:28:25 AM: npm ERR! /opt/buildhome/.npm/_logs/2020-04-14T09_28_25_750Z-debug.log 10:28:25 AM: ERROR: "build:app" exited with 1. 10:28:25 AM: npm ERR! code ELIFECYCLE 10:28:25 AM: npm ERR! errno 1 10:28:25 AM: npm ERR! [email protected] build:npm-run-all --parallel build:** 10:28:25 AM: npm ERR! Exit status 1 10:28:25 AM: npm ERR! 10:28:25 AM: npm ERR! Failed at the [email protected] build script. 10:28:25 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 10:28:25 AM: npm ERR! A complete log of this run can be found in: 10:28:25 AM: npm ERR! /opt/buildhome/.npm/_logs/2020-04-14T09_28_25_772Z-debug.log

I faced the same problem. Solved it by setting the build command in netlify as 'gatsby build'.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonmp picture brandonmp  Β·  3Comments

hobochild picture hobochild  Β·  3Comments

ferMartz picture ferMartz  Β·  3Comments

dustinhorton picture dustinhorton  Β·  3Comments

kalinchernev picture kalinchernev  Β·  3Comments