Can build Gatsby site locally but can't on netlify

Hello,

I’m having issue with the netlify continous deployment of a Gatsby site.
The sitename ist drfaltermeier.netlify.app.

I can build and deploy it to netlify locally from my machine.
But as soon as I try building it on netlify it throws an error.

I have tried:
-recreating the github repo.
-specifying node and npm versions as I have them locally
-deploy with cleared cache

Not sure how I could go from here, as I cannot access the error log.

Without this, the only way to help you would be your repo.

However, you can try disabling any browser extensions, or loading the Netlify page in a different device/browser altogether to see if the log loads.

I can access the deploy log but not this:

10:53:23 AM: npm ERR! A complete log of this run can be found in:
10:53:23 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-03-12T09_53_23_217Z-debug.log

Is there a way to actually access this file in netlify?

Oh, I thought your deploy log was missing.

No, you can’t assess the above file. However, the deploy log should contain the cause of error.

10:49:32 AM: Build ready to start
10:49:34 AM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
10:49:34 AM: build-image tag: v3.7.0
10:49:34 AM: buildbot version: 89fd0aa6bcd88a2db5e5fe57a2179df0d7a1e96e
10:49:34 AM: Fetching cached dependencies
10:49:34 AM: Failed to fetch cache, continuing with build
10:49:34 AM: Starting to prepare the repo for build
10:49:34 AM: No cached dependencies found. Cloning fresh repo
10:49:34 AM: git clone https://github.com/quansenB/Website-Faltermeier
10:49:36 AM: Preparing Git Reference refs/heads/main
10:49:39 AM: Starting build script
10:49:39 AM: Installing dependencies
10:49:39 AM: Python version set to 2.7
10:49:40 AM: Downloading and installing node v14.15.4...
10:49:41 AM: Downloading https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.xz...
10:49:41 AM: Computing checksum with sha256sum
10:49:41 AM: Checksums matched!
10:49:45 AM: Now using node v14.15.4 (npm v6.14.10)
10:49:45 AM: Started restoring cached build plugins
10:49:45 AM: Finished restoring cached build plugins
10:49:45 AM: Attempting ruby version 2.7.1, read from environment
10:49:47 AM: Using ruby version 2.7.1
10:49:47 AM: Using PHP version 5.6
10:49:47 AM: Started restoring cached node modules
10:49:47 AM: Finished restoring cached node modules
10:49:48 AM: Installing NPM modules using NPM version 6.14.10
10:51:16 AM: > yarn@1.22.10 preinstall /opt/build/repo/node_modules/yarn
10:51:16 AM: > :; (node ./preinstall.js > /dev/null 2>&1 || true)
10:51:27 AM: > sharp@0.27.0 install /opt/build/repo/node_modules/sharp
10:51:27 AM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
10:51:29 AM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-linux-x64.tar.br
10:51:32 AM: > puppeteer@3.3.0 install /opt/build/repo/node_modules/puppeteer
10:51:32 AM: > node install.js
10:51:42 AM: Chromium (756035) downloaded to /opt/build/repo/node_modules/puppeteer/.local-chromium/linux-756035
10:51:43 AM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-polyfill/node_modules/core-js
10:51:43 AM: > node -e "try{require('./postinstall')}catch(e){}"
10:51:43 AM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
10:51:43 AM: > node -e "try{require('./postinstall')}catch(e){}"
10:51:43 AM: > core-js@3.9.1 postinstall /opt/build/repo/node_modules/core-js
10:51:43 AM: > node -e "try{require('./postinstall')}catch(e){}"
10:51:43 AM: > core-js-pure@3.9.1 postinstall /opt/build/repo/node_modules/core-js-pure
10:51:43 AM: > node -e "try{require('./postinstall')}catch(e){}"
10:51:43 AM: > esbuild@0.8.55 postinstall /opt/build/repo/node_modules/esbuild
10:51:43 AM: > node install.js
10:51:48 AM: > gatsby-telemetry@2.0.0 postinstall /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/gatsby-telemetry
10:51:48 AM: > node src/postinstall.js || true
10:51:48 AM: > gatsby-telemetry@1.10.1 postinstall /opt/build/repo/node_modules/gatsby-telemetry
10:51:48 AM: > node src/postinstall.js || true
10:51:49 AM: > mozjpeg@7.0.0 postinstall /opt/build/repo/node_modules/mozjpeg
10:51:49 AM: > node lib/install.js
10:51:49 AM:   βœ” mozjpeg pre-build test passed successfully
10:51:49 AM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/node_modules/pngquant-bin
10:51:49 AM: > node lib/install.js
10:51:50 AM:   βœ” pngquant pre-build test passed successfully
10:51:50 AM: > gatsby-cli@2.19.2 postinstall /opt/build/repo/node_modules/gatsby-cli
10:51:50 AM: > node scripts/postinstall.js
10:51:50 AM: > gatsby@2.32.9 postinstall /opt/build/repo/node_modules/gatsby
10:51:50 AM: > node scripts/postinstall.js
10:51:50 AM: > netlify-cli@3.10.6 postinstall /opt/build/repo/node_modules/netlify-cli
10:51:50 AM: > node ./scripts/postinstall.js
10:51:50 AM: Success! Netlify CLI has been installed!
10:51:50 AM: Your device is now configured to use Netlify CLI to deploy and manage your Netlify sites.
10:51:50 AM: Next steps:
10:51:50 AM:   netlify init     Connect or create a Netlify site from current directory
10:51:50 AM:   netlify deploy   Deploy the latest changes to your Netlify site
10:51:50 AM: For more information on the CLI run netlify help
10:51:50 AM: Or visit the docs at https://cli.netlify.com
10:51:56 AM: npm WARN website-faltermeier@0.0.1 No repository field.
10:51:56 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
10:51:56 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:51:56 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
10:51:56 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:51:56 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
10:51:56 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:51:56 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/chokidar/node_modules/fsevents):
10:51:56 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:51:56 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-win32-x64@0.27.10 (node_modules/@netlify/traffic-mesh-agent-win32-x64):
10:51:56 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-win32-x64@0.27.10: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:51:56 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-darwin-x64@0.27.10 (node_modules/@netlify/traffic-mesh-agent-darwin-x64):
10:51:56 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-darwin-x64@0.27.10: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:51:56 AM: added 3839 packages from 1688 contributors and audited 3853 packages in 127.643s
10:52:02 AM: 324 packages are looking for funding
10:52:02 AM:   run `npm fund` for details
10:52:02 AM: found 4 vulnerabilities (2 low, 2 high)
10:52:02 AM:   run `npm audit fix` to fix them, or `npm audit` for details
10:52:02 AM: NPM modules installed
10:52:02 AM: Started restoring cached go cache
10:52:02 AM: Finished restoring cached go cache
10:52:02 AM: go version go1.14.4 linux/amd64
10:52:02 AM: go version go1.14.4 linux/amd64
10:52:02 AM: Installing missing commands
10:52:02 AM: Verify run directory
10:52:04 AM: ​
10:52:04 AM: ────────────────────────────────────────────────────────────────
10:52:04 AM:   Netlify Build                                                 
10:52:04 AM: ────────────────────────────────────────────────────────────────
10:52:04 AM: ​
10:52:04 AM: ❯ Version
10:52:04 AM:   @netlify/build 9.9.3
10:52:04 AM: ​
10:52:04 AM: ❯ Flags
10:52:04 AM:   apiHost: api.netlify.com
10:52:04 AM:   cacheDir: /opt/build/cache
10:52:04 AM:   deployId: 604b392c07b9d10007e39689
10:52:04 AM:   mode: buildbot
10:52:04 AM:   testOpts:
10:52:04 AM:     silentLingeringProcesses: ''
10:52:04 AM: ​
10:52:04 AM: ❯ Current directory
10:52:04 AM:   /opt/build/repo
10:52:04 AM: ​
10:52:04 AM: ❯ Config file
10:52:04 AM:   /opt/build/repo/netlify.toml
10:52:04 AM: ​
10:52:04 AM: ❯ Context
10:52:04 AM:   production
10:52:04 AM: ​
10:52:04 AM: ────────────────────────────────────────────────────────────────
10:52:04 AM:   1. build.command from netlify.toml                            
10:52:04 AM: ────────────────────────────────────────────────────────────────
10:52:04 AM: ​
10:52:04 AM: $ npm run build
10:52:05 AM: > website-faltermeier@0.0.1 build /opt/build/repo
10:52:05 AM: > gatsby build --log-pages
10:52:09 AM: success open and validate gatsby-configs - 0.155s
10:52:10 AM: warning Plugin gatsby-plugin-image is not compatible with your gatsby version 2.32.9 - It requires gatsby@^3.0.0-next.0
10:52:10 AM: warning Plugin gatsby-transformer-sharp is not compatible with your gatsby version 2.32.9 - It requires gatsby@^3.0.0-next.0
10:52:10 AM: warning Plugin gatsby-plugin-sharp is not compatible with your gatsby version 2.32.9 - It requires gatsby@^3.0.0-next.0
10:52:10 AM: warning Plugin gatsby-remark-images is not compatible with your gatsby version 2.32.9 - It requires gatsby@^3.0.0-next.0
10:52:11 AM: success load plugins - 2.195s
10:52:11 AM: success onPreInit - 0.078s
10:52:11 AM: success delete html and css files from previous builds - 0.007s
10:52:11 AM: success initialize cache - 0.010s
10:52:11 AM: success copy gatsby files - 0.089s
10:52:11 AM: success onPreBootstrap - 0.020s
10:52:11 AM: success createSchemaCustomization - 0.244s
10:52:12 AM: success Checking for changed pages - 0.000s
10:52:12 AM: success source and transform nodes - 0.679s
10:52:13 AM: success building schema - 0.919s
10:52:13 AM: info Total nodes: 179, SitePage nodes: 1 (use --verbose for breakdown)
10:52:13 AM: success createPages - 0.001s
10:52:13 AM: success Checking for changed pages - 0.000s
10:52:13 AM: success createPagesStatefully - 0.250s
10:52:13 AM: success update schema - 0.047s
10:52:13 AM: success onPreExtractQueries - 0.005s
10:52:22 AM: success extract queries from components - 9.043s
10:52:22 AM: success write out redirect data - 0.001s
10:52:23 AM: success Build manifest and related icons - 0.668s
10:52:23 AM: success onPostBootstrap - 0.672s
10:52:23 AM: info bootstrap finished - 18.421s
10:52:23 AM: success run static queries - 0.016s - 2/2 125.61/s
10:52:23 AM: warning [gatsby-transformer-sharp] The "fixed" and "fluid" resolvers are now deprecated. Switch to "gatsby-plugin-image" for better performance and a simpler API. See https://gatsby.dev/migrate-images to learn how.
10:52:38 AM: warning Query takes too long:
10:52:38 AM: File path: /opt/build/repo/src/pages/datenschutz.js
10:52:38 AM: URL path: /datenschutz/
10:52:38 AM: warning Query takes too long:
10:52:38 AM: File path: /opt/build/repo/src/pages/impressum.js
10:52:38 AM: URL path: /impressum/
10:52:38 AM: warning Query takes too long:
10:52:38 AM: File path: /opt/build/repo/src/pages/index.js
10:52:38 AM: URL path: /
10:52:38 AM: warning Query takes too long:
10:52:38 AM: File path: /opt/build/repo/src/pages/leistungen.js
10:52:38 AM: URL path: /leistungen/
10:53:23 AM: Killed
10:53:23 AM: npm ERR! code ELIFECYCLE
10:53:23 AM: npm ERR! errno 137
10:53:23 AM: npm ERR! website-faltermeier@0.0.1 build: `gatsby build --log-pages`
10:53:23 AM: npm ERR! Exit status 137
10:53:23 AM: npm ERR!
10:53:23 AM: npm ERR! Failed at the website-faltermeier@0.0.1 build script.
10:53:23 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:53:23 AM: npm ERR! A complete log of this run can be found in:
10:53:23 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-03-12T09_53_23_217Z-debug.log
10:53:23 AM: ​
10:53:23 AM: ────────────────────────────────────────────────────────────────
10:53:23 AM:   "build.command" failed                                        
10:53:23 AM: ────────────────────────────────────────────────────────────────
10:53:23 AM: ​
10:53:23 AM:   Error message
10:53:23 AM:   Command failed with exit code 137: npm run build
10:53:23 AM: ​
10:53:23 AM:   Error location
10:53:23 AM:   In build.command from netlify.toml:
10:53:23 AM:   npm run build
10:53:23 AM: ​
10:53:23 AM:   Resolved config
10:53:23 AM:   build:
10:53:23 AM:     command: npm run build
10:53:23 AM:     commandOrigin: config
10:53:23 AM:     environment:
10:53:23 AM:       - NODE_VERSION
10:53:23 AM:       - NPM_VERSION
10:53:23 AM:     functions: /opt/build/repo/lambda
10:53:23 AM:     publish: /opt/build/repo/public
10:53:23 AM: Caching artifacts
10:53:23 AM: Started saving node modules
10:53:23 AM: Finished saving node modules
10:53:23 AM: Started saving build plugins
10:53:23 AM: Finished saving build plugins
10:53:23 AM: Started saving pip cache
10:53:23 AM: Finished saving pip cache
10:53:23 AM: Started saving emacs cask dependencies
10:53:23 AM: Finished saving emacs cask dependencies
10:53:23 AM: Started saving maven dependencies
10:53:23 AM: Finished saving maven dependencies
10:53:23 AM: Started saving boot dependencies
10:53:23 AM: Finished saving boot dependencies
10:53:23 AM: Started saving rust rustup cache
10:53:23 AM: Finished saving rust rustup cache
10:53:23 AM: Started saving go dependencies
10:53:23 AM: Finished saving go dependencies
10:53:29 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:53:29 AM: Failing build: Failed to build site
10:53:29 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:53:29 AM: Finished processing build request in 3m55.679583101s

I’m not seeing it. Does this information help?

There’s a chance that the process is getting killed due to the 3 GB RAM limit.

Hmm, this would really surprise me, as these are rather small queries. The last one includes one single image, and other than that just some strings(maybe 20).

Is there any way to see how much RAM is used?

On Netlify? I’m not sure you can. However, you can try to profile you application locally. Here’s Gatsby a documentation on that: Performance and Scaling | Gatsby. Not sure if it applies to you though.

I have no problem building it locally. It’s just a small website. 12 sub pages or so in total. I can hardly image it to be a RAM limit issue

Well then, you can wait for the support team to provide you with a better answer.

You can also choose to share your repo (or a demo repo that reproduces the same issue), so others can see what’s happening.

Sure, that’s possible: https://github.com/quansenB/Website-FF

I just downloaded that repo and published it as it is. It worked just fine. Deploy log: Netlify App

Thank you for your efforts. Unfortunately I mistakenly posted the wrong repo here. Sorry for that.

the right one would be: https://github.com/quansenB/Website-Faltermeier

Just out of curiosity, have you tried to switch to gatsby-plugin-image instead of gatsby-transformer-sharp as the log says?

Yes I switched it out, it was related to the gatsby v3 upgrade.

Unfortunately this didn’t solve the issue. It’s present in v2 aswell as v3.

At this point, I guess you’ll have more luck asking this on Gatsby discussions on GitHub. I looked at your code and there is no real cause of the issue that’s obvious. Maybe someone else has better insights.

Hey there @quansenB

Thanks for sharing this question in the Forums! We believe that this a Gatsby issue related to AVIF support. I chatted with one of our Engineers, and a short term fix would be disabling AVIF format in image transformations.

I can see that you filed an issue on this repo (excellent-- thank you for this!!) so please stay tuned to that issue for further information from Gatsby.

Thank you for your help. I can confirm, switching off AVIF fixes this issue.

1 Like

Glad to hear! Thanks again for bringing this up.

Best,
Hillary