Failed during stage 'building site' - Netlify & Gatsby

Netlify Site: hopeful-curie-86a612

Okay, so I’m fairly new to Netlify. I previously deployed my portolio without continuous deployment and now I’m trying it WITH continuous deployment. With that being said, my Strapi Server is being hosted on Heroku.

Here is my build log:

12:49:07 PM: Build ready to start
12:49:08 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
12:49:08 PM: build-image tag: v3.4.1
12:49:08 PM: buildbot version: cdc66b02d86506251d3343610a77385376c8c035
12:49:09 PM: Fetching cached dependencies
12:49:09 PM: Failed to fetch cache, continuing with build
12:49:09 PM: Starting to prepare the repo for build
12:49:09 PM: No cached dependencies found. Cloning fresh repo
12:49:09 PM: git clone https://github.com/girafffene/portfolio2.0
12:49:11 PM: Preparing Git Reference refs/heads/master
12:49:12 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
12:49:12 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
12:49:12 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'gatsby clean && gatsby build' versus 'gatsby build' in the Netlify UI
12:49:13 PM: Starting build script
12:49:13 PM: Installing dependencies
12:49:13 PM: Python version set to 2.7
12:49:14 PM: v12.18.0 is already installed.
12:49:15 PM: Now using node v12.18.0 (npm v6.14.4)
12:49:15 PM: Started restoring cached build plugins
12:49:15 PM: Finished restoring cached build plugins
12:49:15 PM: Attempting ruby version 2.7.1, read from environment
12:49:17 PM: Using ruby version 2.7.1
12:49:17 PM: Using PHP version 5.6
12:49:17 PM: 5.2 is already installed.
12:49:17 PM: Using Swift version 5.2
12:49:17 PM: Started restoring cached node modules
12:49:17 PM: Finished restoring cached node modules
12:49:18 PM: Installing NPM modules using NPM version 6.14.4
12:50:25 PM: > node@8.10.0 preinstall /opt/build/repo/node_modules/node
12:50:25 PM: > node installArchSpecificPackage
12:50:28 PM: + node-linux-x64@8.10.0
12:50:28 PM: added 1 package in 2.195s
12:50:28 PM: found 0 vulnerabilities
12:50:32 PM: > bufferutil@4.0.1 install /opt/build/repo/node_modules/bufferutil
12:50:32 PM: > node-gyp-build
12:50:33 PM: > utf-8-validate@5.0.2 install /opt/build/repo/node_modules/utf-8-validate
12:50:33 PM: > node-gyp-build
12:50:33 PM: > sharp@0.25.4 install /opt/build/repo/node_modules/sharp
12:50:33 PM: > (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
12:50:34 PM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz
12:50:36 PM: prebuild-install WARN This package does not support N-API version undefined
12:50:36 PM: prebuild-install WARN install No prebuilt binaries found (target=undefined runtime=napi arch=x64 libc= platform=linux)
12:50:38 PM: make: Entering directory '/opt/build/repo/node_modules/sharp/build'
12:50:38 PM:   CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
12:50:38 PM:   AR(target) Release/obj.target/../node-addon-api/nothing.a
12:50:38 PM:   COPY Release/nothing.a
12:50:38 PM:   TOUCH Release/obj.target/libvips-cpp.stamp
12:50:38 PM:   CXX(target) Release/obj.target/sharp/src/common.o
12:50:38 PM: In file included from ../src/common.cc:22:0:
12:50:38 PM: /opt/build/repo/node_modules/node-addon-api/napi.h:1935:33: error: ‘napi_callback_scope’ has not been declared
12:50:38 PM:      CallbackScope(napi_env env, napi_callback_scope scope);
12:50:38 PM:                                  ^
12:50:38 PM: /opt/build/repo/node_modules/node-addon-api/napi.h:1942:14: error: expected type-specifier before ‘napi_callback_scope’
12:50:38 PM:      operator napi_callback_scope() const;
12:50:38 PM:               ^
12:50:38 PM: /opt/build/repo/node_modules/node-addon-api/napi.h:1948:5: error: ‘napi_callback_scope’ does not name a type
12:50:38 PM:      napi_callback_scope _scope;
12:50:38 PM:      ^
12:50:39 PM: In file included from /opt/build/repo/node_modules/node-addon-api/napi.h:2441:0,
12:50:39 PM:                  from ../src/common.cc:22:
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h:4051:17: error: ‘napi_callback_scope’ has not been declared
12:50:39 PM:    napi_env env, napi_callback_scope scope) : _env(env), _scope(scope) {
12:50:39 PM:                  ^
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h: In constructor ‘Napi::CallbackScope::CallbackScope(napi_env, int)’:
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h:4051:57: error: class ‘Napi::CallbackScope’ does not have any field named ‘_scope’
12:50:39 PM:    napi_env env, napi_callback_scope scope) : _env(env), _scope(scope) {
12:50:39 PM:                                                          ^
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h: In constructor ‘Napi::CallbackScope::CallbackScope(napi_env, napi_async_context)’:
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h:4057:41: error: ‘_scope’ was not declared in this scope
12:50:39 PM:        _env, Object::New(env), context, &_scope);
12:50:39 PM:                                          ^
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h:4057:47: error: ‘napi_open_callback_scope’ was not declared in this scope
12:50:39 PM:        _env, Object::New(env), context, &_scope);
12:50:39 PM:                                                ^
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h: In destructor ‘virtual Napi::CallbackScope::~CallbackScope()’:
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h:4062:56: error: ‘_scope’ was not declared in this scope
12:50:39 PM:    napi_status status = napi_close_callback_scope(_env, _scope);
12:50:39 PM:                                                         ^
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h:4062:62: error: ‘napi_close_callback_scope’ was not declared in this scope
12:50:39 PM:    napi_status status = napi_close_callback_scope(_env, _scope);
12:50:39 PM:                                                               ^
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h: At global scope:
12:50:39 PM: /opt/build/repo/node_modules/node-addon-api/napi-inl.h:4068:32: error: expected type-specifier before ‘napi_callback_scope’
12:50:39 PM:  inline CallbackScope::operator napi_callback_scope() const {
12:50:39 PM:                                 ^
12:50:39 PM: cc1plus: warning: unrecognized command line option ‘-Wno-cast-function-type’
12:50:39 PM: sharp.target.mk:129: recipe for target 'Release/obj.target/sharp/src/common.o' failed
12:50:39 PM: make: *** [Release/obj.target/sharp/src/common.o] Error 1
12:50:39 PM: make: Leaving directory '/opt/build/repo/node_modules/sharp/build'
12:50:39 PM: gyp ERR! build error
12:50:39 PM: gyp ERR! stack Error: `make` failed with exit code: 2
12:50:39 PM: gyp ERR! stack     at ChildProcess.onExit (/opt/buildhome/.nvm/versions/node/v12.18.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
12:50:39 PM: gyp ERR! stack     at emitTwo (events.js:126:13)
12:50:39 PM: gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
12:50:39 PM: gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
12:50:39 PM: gyp ERR! System Linux 4.19.112+
12:50:39 PM: gyp ERR! command "/opt/build/repo/node_modules/node/bin/node" "/opt/buildhome/.nvm/versions/node/v12.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
12:50:39 PM: gyp ERR! cwd /opt/build/repo/node_modules/sharp
12:50:39 PM: gyp ERR! node -v v8.10.0
12:50:39 PM: gyp ERR! node-gyp -v v5.1.0
12:50:39 PM: gyp ERR! not ok
12:50:43 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/watchpack/node_modules/fsevents):
12:50:43 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:50:43 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules/fsevents):
12:50:43 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:50:43 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/gatsby/node_modules/fsevents):
12:50:43 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:50:43 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/gatsby-recipes/node_modules/fsevents):
12:50:43 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:50:43 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/gatsby-plugin-page-creator/node_modules/fsevents):
12:50:43 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:50:43 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/gatsby-page-utils/node_modules/fsevents):
12:50:43 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:50:43 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
12:50:43 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:50:43 PM: npm ERR! code ELIFECYCLE
12:50:43 PM: npm ERR! errno 1
12:50:43 PM: npm ERR! sharp@0.25.4 install: `(node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)`
12:50:43 PM: npm ERR! Exit status 1
12:50:43 PM: npm ERR!
12:50:43 PM: npm ERR! Failed at the sharp@0.25.4 install script.
12:50:43 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:50:43 PM: npm ERR! A complete log of this run can be found in:
12:50:43 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-10-28T19_50_43_848Z-debug.log
12:50:43 PM: Error during NPM install
12:50:43 PM: Build was terminated: Build script returned non-zero exit code: 1
12:50:43 PM: Failing build: Failed to build site
12:50:43 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
12:50:44 PM: Finished processing build request in 1m35.657177553s

If I’m missing anything please let me know. Someone help :sob:

I tried deploying a clone of your repo to my Netlify account. The only difference was that I deleted the package-lock.json file.

However, in your case, the problem is the failure of a Node Module (Specifically sharp). It might have been a temporary problem because I didn’t face it in my deploy process (or it might as well be so because I deleted the package-lock.json).

However, after the Node Modules got installed, the depoly still failed and here’s the build log:

1:54:46 AM: ┌─────────────────────────────┐
1:54:46 AM: │        Netlify Build        │
1:54:46 AM: └─────────────────────────────┘
1:54:46 AM: ​
1:54:46 AM: ❯ Version
1:54:46 AM:   @netlify/build 5.0.3
1:54:46 AM: ​
1:54:46 AM: ❯ Flags
1:54:46 AM:   deployId: 5f99d3293603c944504ec367
1:54:46 AM:   mode: buildbot
1:54:46 AM: ​
1:54:46 AM: ❯ Current directory
1:54:46 AM:   /opt/build/repo
1:54:46 AM: ​
1:54:46 AM: ❯ Config file
1:54:46 AM:   /opt/build/repo/netlify.toml
1:54:46 AM: ​
1:54:46 AM: ❯ Context
1:54:46 AM:   production
1:54:46 AM: ​
1:54:46 AM: ┌────────────────────────────────────┐
1:54:46 AM: │ 1. build.command from netlify.toml │
1:54:46 AM: └────────────────────────────────────┘
1:54:46 AM: ​
1:54:46 AM: $ gatsby clean && gatsby build
1:54:47 AM: /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/init-starter.js:104
1:54:47 AM:   } catch {
1:54:47 AM:           ^
1:54:47 AM: SyntaxError: Unexpected token {
1:54:47 AM:     at createScript (vm.js:80:10)
1:54:47 AM:     at Object.runInThisContext (vm.js:139:10)
1:54:47 AM:     at Module._compile (module.js:617:28)
1:54:47 AM:     at Object.Module._extensions..js (module.js:664:10)
1:54:47 AM:     at Module.load (module.js:566:32)
1:54:47 AM:     at tryModuleLoad (module.js:506:12)
1:54:47 AM:     at Function.Module._load (module.js:498:3)
1:54:47 AM:     at Module.require (module.js:597:17)
1:54:47 AM:     at require (internal/module.js:11:18)
1:54:47 AM:     at Object.<anonymous> (/opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js:28:20)
1:54:47 AM: ​
1:54:47 AM: ┌─────────────────────────────┐
1:54:47 AM: │   "build.command" failed    │
1:54:47 AM: └─────────────────────────────┘
1:54:47 AM: ​
1:54:47 AM:   Error message
1:54:47 AM:   Command failed with exit code 7: gatsby clean && gatsby build
1:54:47 AM: ​
1:54:47 AM:   Error location
1:54:47 AM:   In build.command from netlify.toml:
1:54:47 AM:   gatsby clean && gatsby build
1:54:47 AM: ​
1:54:47 AM:   Resolved config
1:54:47 AM:   build:
1:54:47 AM:     base: /opt/build/repo
1:54:47 AM:     command: gatsby clean && gatsby build
1:54:47 AM:     commandOrigin: config
1:54:47 AM:     publish: /opt/build/repo/public
1:54:47 AM: Caching artifacts
1:54:47 AM: Started saving node modules
1:54:47 AM: Finished saving node modules
1:54:47 AM: Started saving build plugins
1:54:47 AM: Finished saving build plugins
1:54:47 AM: Started saving pip cache
1:54:47 AM: Finished saving pip cache
1:54:47 AM: Started saving emacs cask dependencies
1:54:47 AM: Finished saving emacs cask dependencies
1:54:47 AM: Started saving maven dependencies
1:54:47 AM: Finished saving maven dependencies
1:54:47 AM: Started saving boot dependencies
1:54:47 AM: Finished saving boot dependencies
1:54:47 AM: Started saving go dependencies
1:54:47 AM: Finished saving go dependencies
1:54:50 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:54:50 AM: Failing build: Failed to build site
1:54:50 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
1:54:50 AM: Finished processing build request in 1m43.703925517s

This time, it’s because of an error thrown by gatsby-cli module. I’ll update it I find something more useful, or it’s anyways open for others including yourself to try and fix this.

By the way, the website builds fine locally, so, that’s one good thing.

1 Like

Thank you for taking the time to look this over!

Got it. The problem was that you had "node": "^8.10.0", in your package.json. Gatsby needs a minimum of Node 10.13 and even though Netlify by default uses Node 12, I guess, because of that dependency it was ending up using Node 8. Thus, the error. Remove the dependency from your package.json and the build should be fine.

AHA!
I needed node@8.10.0 in my server, not my front-end, looks like I downgraded the wrong file :woman_facepalming:
Thank you!

2 Likes