Build fails on Gatsby & Sanity site deploy with error for invalid lock file

Hi,

My personal portfolio site is running a gatsby 3.0.4 front-end with a sanity 2.19.4 backend, and I was recently trying to merge one of my feature branches into my main branch, but its not passing the Netlify checks for Header Rules, Mixed Content, Pages changed, and Redirect rules. When I open the Netlify app the build fails, and does so even when I’ve cleared cache to rebuild. It worked when I initially set up the site, so I have had successful build deploys in the past.

It seems like some of the first errors are regarding an invalid lock file when deploying, especially related to older versions of sanity (my backend). Do you know what I should change to deploy more successfully (not include the lockfile in my git commit?)

Here’s my site name
https://christianbergstrom-sanity-gatsby-portfolio-studio.netlify.app

Here’s my build settings
Base Directory: /
Build Command: npm run build-studio && cp studio/netlify.toml studio/dist
Publish directory: //studio/dist
Builds: Active

Here’s the deploy log:

11:10:40 PM: Build ready to start
11:10:42 PM: build-image version: c6001ed68662a13e5deb24abec2b46058c58248a
11:10:42 PM: build-image tag: v3.9.0
11:10:42 PM: buildbot version: a7ed393d7802bf453be684c29d76700ec4b7cbba
11:10:42 PM: Fetching cached dependencies
11:10:42 PM: Failed to fetch cache, continuing with build
11:10:42 PM: Starting to prepare the repo for build
11:10:42 PM: No cached dependencies found. Cloning fresh repo
11:10:42 PM: git clone https://github.com/ccbergstrom/christianbergstrom-sanity-gatsby-portfolio
11:10:44 PM: Preparing Git Reference pull/5/head
11:10:45 PM: Parsing package.json dependencies
11:10:45 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
11:10:45 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'studio/dist' versus '/studio/dist' in the Netlify UI
11:10:46 PM: Starting build script
11:10:46 PM: Installing dependencies
11:10:46 PM: Python version set to 2.7
11:10:47 PM: v12.18.0 is already installed.
11:10:48 PM: Now using node v12.18.0 (npm v6.14.4)
11:10:48 PM: Started restoring cached build plugins
11:10:48 PM: Finished restoring cached build plugins
11:10:48 PM: Attempting ruby version 2.7.1, read from environment
11:10:49 PM: Required ruby-2.7.1 is not installed - installing.
11:10:49 PM: Searching for binary rubies, this might take some time.
11:10:50 PM: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.7.1.tar.bz2
11:10:50 PM: Checking requirements for ubuntu.
11:10:50 PM: Requirements installation successful.
11:10:50 PM: ruby-2.7.1 - #configure
11:10:50 PM: ruby-2.7.1 - #download
11:10:52 PM: ruby-2.7.1 - #validate archive
11:10:57 PM: ruby-2.7.1 - #extract
11:11:00 PM: ruby-2.7.1 - #validate binary
11:11:01 PM: ruby-2.7.1 - #setup
11:11:01 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1@global
11:11:02 PM: ruby-2.7.1 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems........................................
11:11:02 PM: ruby-2.7.1 - #generating global wrappers........
11:11:02 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1
11:11:02 PM: ruby-2.7.1 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
11:11:03 PM: ruby-2.7.1 - #generating default wrappers........
11:11:03 PM: Using /opt/buildhome/.rvm/gems/ruby-2.7.1
11:11:04 PM: Using ruby version 2.7.1
11:11:04 PM: Using PHP version 5.6
11:11:04 PM: Started restoring cached node modules
11:11:04 PM: Finished restoring cached node modules
11:11:04 PM: Installing NPM modules using NPM version 6.14.4
11:11:18 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
11:11:18 PM: > sanity-gatsby-portfolio@1.0.0 postinstall /opt/build/repo
11:11:18 PM: > lerna bootstrap
11:11:18 PM: lerna notice cli v3.16.3
11:11:18 PM: lerna info ci enabled
11:11:18 PM: lerna info Bootstrapping 2 packages
11:11:18 PM: lerna info Installing external dependencies
11:11:19 PM: lerna ERR! npm ci exited 1 in 'sanity-gatsby-portfolio-studio'
11:11:19 PM: lerna ERR! npm ci stderr:
11:11:19 PM: npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
11:11:19 PM: npm ERR!
11:11:19 PM: npm ERR!
11:11:19 PM: npm ERR! Invalid: lock file's @sanity/base@2.1.3 does not satisfy @sanity/base@^2.19.4npm ERR! Invalid: lock file's @sanity/cli@2.1.0 does not satisfy @sanity/cli@^2.19.1npm ERR! Invalid: lock file's @sanity/components@2.1.0 does not satisfy @sanity/components@^2.14.0npm ERR! Invalid: lock file's @sanity/core@2.1.2 does not satisfy @sanity/core@^2.19.2npm ERR! Invalid: lock file's @sanity/dashboard@2.1.0 does not satisfy @sanity/dashboard@^2.19.4npm ERR! Invalid: lock file's @sanity/default-layout@2.1.3 does not satisfy @sanity/default-layout@^2.19.4npm ERR! Invalid: lock file's @sanity/default-login@2.1.0 does not satisfy @sanity/default-login@^2.19.0npm ERR! Invalid: lock file's @sanity/desk-tool@2.1.3 does not satisfy @sanity/desk-tool@^2.19.4npm ERR! Invalid: lock file's @sanity/studio-hints@2.1.0 does not satisfy @sanity/studio-hints@^2.19.0npm ERR!
11:11:19 PM: npm ERR! A complete log of this run can be found in:
11:11:19 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-20T06_11_19_617Z-debug.log
11:11:19 PM: lerna ERR! npm ci exited 1 in 'sanity-gatsby-portfolio-studio'
11:11:19 PM: lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately.
11:11:19 PM: npm ERR! code ELIFECYCLE
11:11:19 PM: npm ERR! errno 1
11:11:19 PM: npm ERR! sanity-gatsby-portfolio@1.0.0 postinstall: `lerna bootstrap`
11:11:19 PM: npm ERR! Exit status 1
11:11:19 PM: npm ERR!
11:11:19 PM: npm ERR! Failed at the sanity-gatsby-portfolio@1.0.0 postinstall script.
11:11:19 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
11:11:19 PM: npm ERR! A complete log of this run can be found in:
11:11:19 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-20T06_11_19_708Z-debug.log
11:11:19 PM: Error during NPM install
11:11:19 PM: Build was terminated: Build script returned non-zero exit code: 1
11:11:19 PM: Creating deploy upload records
11:11:19 PM: Failing build: Failed to build site
11:11:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
11:11:19 PM: Finished processing build request in 37.863052998s

Welcome to the forums @ccbergstrom

Your issue seems very similar (if not the same) as that outlined in Netlify Deploy Command failed with exit code 254: npm run build-studio && cp studio/netlify.toml studio/dist which was asked a little more than a week ago.

Ah thanks @coelmay ! I updated my deploy settings for the studio to match what you wrote to an extent. I also removed my yarn-lock and package-lock files that were causing problems. They got regenerated and it seems like although I tried another build that failed, it got up to a different point at this time.

My updated deploy settings:
Base Directory: /studio
Build Command: npm run build
Publish Directory: /studio/dist

4:38:30 PM: Build ready to start
4:38:32 PM: build-image version: c6001ed68662a13e5deb24abec2b46058c58248a
4:38:32 PM: build-image tag: v3.9.0
4:38:32 PM: buildbot version: 97a6b2cacb208d0706f4c310f966af375d45e5e6
4:38:32 PM: Fetching cached dependencies
4:38:32 PM: Failed to fetch cache, continuing with build
4:38:32 PM: Starting to prepare the repo for build
4:38:32 PM: No cached dependencies found. Cloning fresh repo
4:38:32 PM: git clone https://github.com/ccbergstrom/christianbergstrom-sanity-gatsby-portfolio
4:38:34 PM: Preparing Git Reference pull/5/head
4:38:35 PM: Parsing package.json dependencies
4:38:35 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
4:38:35 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'web/public' versus '/web/public' in the Netlify UI
4:38:36 PM: Starting build script
4:38:36 PM: Installing dependencies
4:38:36 PM: Python version set to 2.7
4:38:37 PM: v12.18.0 is already installed.
4:38:37 PM: Now using node v12.18.0 (npm v6.14.4)
4:38:37 PM: Started restoring cached build plugins
4:38:37 PM: Finished restoring cached build plugins
4:38:38 PM: Attempting ruby version 2.7.1, read from environment
4:38:39 PM: Required ruby-2.7.1 is not installed - installing.
4:38:39 PM: Searching for binary rubies, this might take some time.
4:38:39 PM: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.7.1.tar.bz2
4:38:39 PM: Checking requirements for ubuntu.
4:38:40 PM: Requirements installation successful.
4:38:40 PM: ruby-2.7.1 - #configure
4:38:40 PM: ruby-2.7.1 - #download
4:38:41 PM: ruby-2.7.1 - #validate archive
4:38:46 PM: ruby-2.7.1 - #extract
4:38:48 PM: ruby-2.7.1 - #validate binary
4:38:49 PM: ruby-2.7.1 - #setup
4:38:49 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1@global
4:38:49 PM: ruby-2.7.1 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems........................................
4:38:50 PM: ruby-2.7.1 - #generating global wrappers........
4:38:50 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1
4:38:50 PM: ruby-2.7.1 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
4:38:51 PM: ruby-2.7.1 - #generating default wrappers........
4:38:51 PM: Using /opt/buildhome/.rvm/gems/ruby-2.7.1
4:38:52 PM: Using ruby version 2.7.1
4:38:52 PM: Using PHP version 5.6
4:38:52 PM: Started restoring cached node modules
4:38:52 PM: Finished restoring cached node modules
4:38:52 PM: Installing NPM modules using NPM version 6.14.4
4:39:04 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
4:39:04 PM: > sanity-gatsby-portfolio@1.0.0 postinstall /opt/build/repo
4:39:04 PM: > lerna bootstrap
4:39:04 PM: lerna notice cli v3.16.3
4:39:04 PM: lerna info ci enabled
4:39:04 PM: lerna info Bootstrapping 2 packages
4:39:05 PM: lerna info Installing external dependencies
4:40:00 PM: lerna info Symlinking packages and binaries
4:40:00 PM: lerna success Bootstrapped 2 packages
4:40:01 PM: added 715 packages from 382 contributors and audited 715 packages in 67.882s
4:40:01 PM: 26 packages are looking for funding
4:40:01 PM:   run `npm fund` for details
4:40:01 PM: found 550 vulnerabilities (115 low, 281 moderate, 151 high, 3 critical)
4:40:01 PM:   run `npm audit fix` to fix them, or `npm audit` for details
4:40:01 PM: NPM modules installed
4:40:01 PM: Started restoring cached go cache
4:40:01 PM: Finished restoring cached go cache
4:40:01 PM: go version go1.14.4 linux/amd64
4:40:01 PM: go version go1.14.4 linux/amd64
4:40:01 PM: Installing missing commands
4:40:01 PM: Verify run directory
4:40:03 PM: ​
4:40:03 PM: ────────────────────────────────────────────────────────────────
4:40:03 PM:   Netlify Build                                                 
4:40:03 PM: ────────────────────────────────────────────────────────────────
4:40:03 PM: ​
4:40:03 PM: ❯ Version
4:40:03 PM:   @netlify/build 18.12.0
4:40:03 PM: ​
4:40:03 PM: ❯ Flags
4:40:03 PM:   baseRelDir: true
4:40:03 PM:   buildId: 614a6cf67c4cb200070c0e90
4:40:03 PM:   deployId: 614a6cf67c4cb200070c0e92
4:40:03 PM: ​
4:40:03 PM: ❯ Current directory
4:40:03 PM:   /opt/build/repo
4:40:03 PM: ​
4:40:03 PM: ❯ Config file
4:40:03 PM:   No config file was defined: using default values.
4:40:03 PM: ​
4:40:03 PM: ❯ Context
4:40:03 PM:   deploy-preview
4:40:03 PM: ​
4:40:03 PM: ────────────────────────────────────────────────────────────────
4:40:03 PM:   1. Build command from Netlify app                             
4:40:03 PM: ────────────────────────────────────────────────────────────────
4:40:03 PM: ​
4:40:03 PM: $ npm run build-web
4:40:03 PM: > sanity-gatsby-portfolio@1.0.0 build-web /opt/build/repo
4:40:03 PM: > lerna bootstrap && (cd studio && SANITY_AUTH_TOKEN=$SANITY_DEPLOY_STUDIO_TOKEN npm run graphql-deploy) && (cd web && npm run build)
4:40:04 PM: lerna notice cli v3.16.3
4:40:04 PM: lerna info ci enabled
4:40:04 PM: lerna info Bootstrapping 2 packages
4:40:04 PM: lerna info Symlinking packages and binaries
4:40:04 PM: lerna success Bootstrapped 2 packages
4:40:04 PM: > sanity-gatsby-portfolio-studio@1.0.5 graphql-deploy /opt/build/repo/studio
4:40:04 PM: > sanity graphql deploy --playground
4:40:05 PM: Dataset: production
4:40:05 PM: Tag: default
4:40:09 PM: GraphQL API deployed to:
4:40:09 PM: https://6tsvlu9x.api.sanity.io/v1/graphql/production/default
4:40:10 PM: > sanity-gatsby-portfolio-web@1.0.2 build /opt/build/repo/web
4:40:10 PM: > gatsby build
4:40:13 PM: success open and validate gatsby-configs, load plugins - 0.904s
4:40:13 PM: success onPreInit - 0.004s
4:40:13 PM: success initialize cache - 0.046s
4:40:13 PM: success copy gatsby files - 0.067s
4:40:14 PM: success Compiling Gatsby Functions - 0.360s
4:40:14 PM: info [sanity] Fetching remote GraphQL schema
4:40:14 PM: info [sanity] Transforming to Gatsby-compatible GraphQL SDL
4:40:14 PM: info [sanity] Stitching GraphQL schemas from SDL
4:40:14 PM: success onPreBootstrap - 0.667s
4:40:14 PM: success createSchemaCustomization - 0.020s
4:40:14 PM: info [sanity] Fetching export stream for dataset
4:40:15 PM: info [sanity] Done! Exported 90 documents.
4:40:15 PM: warning The gatsby-plugin-sanity-image plugin has generated no Gatsby nodes. Do you need it?
4:40:15 PM: success Checking for changed pages - 0.000s
4:40:15 PM: success source and transform nodes - 0.923s
4:40:18 PM: success building schema - 2.878s
4:40:18 PM: success createPages - 0.220s
4:40:18 PM: success createPagesStatefully - 0.300s
4:40:18 PM: info Total nodes: 138, SitePage nodes: 15 (use --verbose for breakdown)
4:40:18 PM: success Checking for changed pages - 0.000s
4:40:19 PM: success update schema - 0.595s
4:40:19 PM: success onPreExtractQueries - 0.004s
4:40:22 PM: success extract queries from components - 3.319s
4:40:22 PM: success write out redirect data - 0.001s
4:40:22 PM: success Build manifest and related icons - 0.088s
4:40:22 PM: success onPostBootstrap - 0.089s
4:40:22 PM: info bootstrap finished - 12.891s
4:40:22 PM: success run static queries - 0.008s - 2/2 253.63/s
4:40:23 PM: success run page queries - 0.057s - 15/15 263.85/s
4:40:23 PM: success write out requires - 0.005s
4:40:29 PM: warning β €
4:40:29 PM: warning warn - You have enabled the JIT engine which is currently in preview.
4:40:29 PM: warning warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
4:41:00 PM: failed Building production JavaScript and CSS bundles - 37.013s
4:41:00 PM: error Generating JavaScript bundles failed
4:41:00 PM: Can't resolve '@artsy/fresnel' in '/opt/build/repo/web/node_modules/gatsby-plugin-fresnel'
4:41:00 PM: If you're trying to use a package make sure that '@artsy/fresnel' is installed. If you're trying to use a local file make sure that the path is correct.
4:41:00 PM: npm ERR! code ELIFECYCLE
4:41:00 PM: npm ERR! errno 1
4:41:00 PM: npm ERR! sanity-gatsby-portfolio-web@1.0.2 build: `gatsby build`
4:41:00 PM: npm ERR! Exit status 1
4:41:00 PM: npm ERR!
4:41:00 PM: npm ERR! Failed at the sanity-gatsby-portfolio-web@1.0.2 build script.
4:41:00 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
4:41:00 PM: npm ERR! A complete log of this run can be found in:
4:41:00 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-21T23_41_00_191Z-debug.log
4:41:00 PM: npm ERR! code ELIFECYCLE
4:41:00 PM: npm ERR! errno 1
4:41:00 PM: npm ERR! sanity-gatsby-portfolio@1.0.0 build-web: `lerna bootstrap && (cd studio && SANITY_AUTH_TOKEN=$SANITY_DEPLOY_STUDIO_TOKEN npm run graphql-deploy) && (cd web && npm run build)`
4:41:00 PM: npm ERR! Exit status 1
4:41:00 PM: npm ERR!
4:41:00 PM: npm ERR! Failed at the sanity-gatsby-portfolio@1.0.0 build-web script.
4:41:00 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
4:41:00 PM: npm ERR! A complete log of this run can be found in:
4:41:00 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-21T23_41_00_207Z-debug.log
4:41:00 PM: ​
4:41:00 PM: ────────────────────────────────────────────────────────────────
4:41:00 PM:   "build.command" failed                                        
4:41:00 PM: ────────────────────────────────────────────────────────────────
4:41:00 PM: ​
4:41:00 PM:   Error message
4:41:00 PM:   Command failed with exit code 1: npm run build-web
4:41:00 PM: ​
4:41:00 PM:   Error location
4:41:00 PM:   In Build command from Netlify app:
4:41:00 PM:   npm run build-web
4:41:00 PM: ​
4:41:00 PM:   Resolved config
4:41:00 PM:   build:
4:41:00 PM:     base: /opt/build/repo
4:41:00 PM:     command: npm run build-web
4:41:00 PM:     commandOrigin: ui
4:41:00 PM:     environment:
4:41:00 PM:       - REVIEW_ID
4:41:00 PM:       - SANITY_DEPLOY_STUDIO_TOKEN
4:41:00 PM:     publish: /opt/build/repo/web/public
4:41:00 PM:     publishOrigin: ui
4:41:00 PM: Caching artifacts
4:41:00 PM: Started saving node modules
4:41:00 PM: Finished saving node modules
4:41:00 PM: Started saving build plugins
4:41:00 PM: Finished saving build plugins
4:41:00 PM: Started saving pip cache
4:41:00 PM: Finished saving pip cache
4:41:00 PM: Started saving emacs cask dependencies
4:41:00 PM: Finished saving emacs cask dependencies
4:41:00 PM: Started saving maven dependencies
4:41:00 PM: Finished saving maven dependencies
4:41:00 PM: Started saving boot dependencies
4:41:00 PM: Finished saving boot dependencies
4:41:00 PM: Started saving rust rustup cache
4:41:00 PM: Finished saving rust rustup cache
4:41:00 PM: Started saving go dependencies
4:41:00 PM: Finished saving go dependencies
4:41:03 PM: Cached ruby version 2.7.1
4:41:03 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:41:03 PM: Creating deploy upload records
4:41:03 PM: Failing build: Failed to build site
4:41:03 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:41:03 PM: Finished processing build request in 2m31.570765269s

What you add @artsy/fresnel as a dependency in your package.json?

@coelmay realized that @artsy/fresnel was more recently updated then the version of the gatsby plugin, so I removed that plugin and replaced it with a similar one that didn’t have dependencies and had been updated recently and since then my deploys built perfectly. Thanks for your help!

1 Like

I’m having a really hard time with Sanity / Gatsby portfolio starter. I’ve used it before with no issue but this last project has been hell-ish. I’ve tried every tip I’ve read on posts about previous experiences of this build fail. If anyone could help me I’d be forever in your debt. I’ve been round in circles so much before posting on here.

4:28:48 PM: Build ready to start
4:28:50 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
4:28:50 PM: build-image tag: v4.8.0
4:28:50 PM: buildbot version: d7330f24833f29d0263d28116347ab83094a2561
4:28:50 PM: Fetching cached dependencies
4:28:50 PM: Failed to fetch cache, continuing with build
4:28:50 PM: Starting to prepare the repo for build
4:28:50 PM: No cached dependencies found. Cloning fresh repo
4:28:50 PM: git clone https://github.com/tomwrankmore/house-of-dinosaur-site-2022
4:28:51 PM: Preparing Git Reference refs/heads/main
4:28:52 PM: Parsing package.json dependencies
4:28:52 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
4:28:52 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'web/public' versus '/web/public' in the Netlify UI
4:28:53 PM: Starting build script
4:28:53 PM: Installing dependencies
4:28:53 PM: Python version set to 2.7
4:28:53 PM: Downloading and installing node v16.15.1...
4:28:53 PM: Downloading https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.xz...
4:28:54 PM: Computing checksum with sha256sum
4:28:54 PM: Checksums matched!
4:28:56 PM: Now using node v16.15.1 (npm v8.11.0)
4:28:56 PM: Started restoring cached build plugins
4:28:56 PM: Finished restoring cached build plugins
4:28:56 PM: Attempting ruby version 2.7.2, read from environment
4:28:57 PM: Using ruby version 2.7.2
4:28:58 PM: Using PHP version 8.0
4:28:58 PM: No npm workspaces detected
4:28:58 PM: Started restoring cached node modules
4:28:58 PM: Finished restoring cached node modules
4:28:58 PM: Installing NPM modules using NPM version 8.11.0
4:28:58 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
4:28:58 PM: npm WARN config location in the cache, and they are managed by
4:28:58 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
4:28:59 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
4:28:59 PM: npm WARN config location in the cache, and they are managed by
4:28:59 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
4:29:02 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
4:29:03 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
4:29:03 PM: npm WARN deprecated read-package-tree@5.3.1: The functionality that this package provided is now in @npmcli/arborist
4:29:03 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
4:29:07 PM: > sanity-gatsby-portfolio@0.0.0 postinstall
4:29:07 PM: > lerna bootstrap
4:29:07 PM: lerna notice cli v4.0.0
4:29:07 PM: lerna info ci enabled
4:29:07 PM: lerna info Bootstrapping 2 packages
4:29:08 PM: lerna info Installing external dependencies
4:29:10 PM: lerna ERR! npm ci exited 1 in 'sanity-gatsby-portfolio-studio'
4:29:10 PM: lerna ERR! npm ci stderr:
4:29:10 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
4:29:10 PM: npm WARN config location in the cache, and they are managed by
4:29:10 PM: Creating deploy upload records
4:29:10 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
4:29:10 PM: npm WARN ERESOLVE overriding peer dependency
4:29:10 PM: npm WARN While resolving: @hot-loader/react-dom@16.14.0
4:29:10 PM: npm WARN Found: react@17.0.2
4:29:10 PM: npm WARN node_modules/react
4:29:10 PM: npm WARN   react@"^17.0.2" from the root project
4:29:10 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
4:29:10 PM: npm WARN   41 more (@reach/auto-id, @reach/utils, @sanity/base, ...)
4:29:10 PM: npm WARN
4:29:10 PM: npm WARN Could not resolve dependency:
4:29:10 PM: npm WARN peer react@"^16.14.0" from @hot-loader/react-dom@16.14.0
4:29:10 PM: npm WARN node_modules/@hot-loader/react-dom
4:29:10 PM: npm WARN   @hot-loader/react-dom@"^16.9.0-4.12.11" from @sanity/server@2.25.0
4:29:10 PM: npm WARN   node_modules/@sanity/server
4:29:10 PM: npm WARN
4:29:10 PM: npm WARN Conflicting peer dependency: react@16.14.0
4:29:10 PM: npm WARN node_modules/react
4:29:10 PM: npm WARN   peer react@"^16.14.0" from @hot-loader/react-dom@16.14.0
4:29:10 PM: npm WARN   node_modules/@hot-loader/react-dom
4:29:10 PM: npm WARN     @hot-loader/react-dom@"^16.9.0-4.12.11" from @sanity/server@2.25.0
4:29:10 PM: npm WARN     node_modules/@sanity/server
4:29:10 PM: npm WARN ERESOLVE overriding peer dependency
4:29:10 PM: npm WARN While resolving: @typescript-eslint/parser@1.13.0
4:29:10 PM: npm WARN Found: eslint@8.8.0
4:29:10 PM: npm WARN node_modules/eslint
4:29:10 PM: npm WARN   dev eslint@"^8.3.0" from the root project
4:29:10 PM: npm WARN   9 more (@typescript-eslint/experimental-utils, babel-eslint, ...)
4:29:10 PM: npm WARN
4:29:10 PM: npm WARN Could not resolve dependency:
4:29:10 PM: npm WARN peer eslint@"^5.0.0" from @typescript-eslint/parser@1.13.0
4:29:10 PM: npm WARN node_modules/@typescript-eslint/parser
4:29:10 PM: npm WARN   @typescript-eslint/parser@"^1.10.2" from prettier-eslint@9.0.2
4:29:10 PM: npm WARN   node_modules/prettier-eslint
4:29:10 PM: npm WARN
4:29:10 PM: npm WARN Conflicting peer dependency: eslint@5.16.0
4:29:10 PM: npm WARN node_modules/eslint
4:29:10 PM: npm WARN   peer eslint@"^5.0.0" from @typescript-eslint/parser@1.13.0
4:29:10 PM: npm WARN   node_modules/@typescript-eslint/parser
4:29:10 PM: npm WARN     @typescript-eslint/parser@"^1.10.2" from prettier-eslint@9.0.2
4:29:10 PM: npm WARN     node_modules/prettier-eslint
4:29:10 PM: npm ERR! code ERESOLVE
4:29:10 PM: npm ERR! ERESOLVE could not resolve
4:29:10 PM: npm ERR!
4:29:10 PM: npm ERR! While resolving: eslint-config-standard@16.0.3
4:29:10 PM: npm ERR! Found: eslint@8.8.0
4:29:10 PM: npm ERR! node_modules/eslint
4:29:10 PM: npm ERR!   dev eslint@"^8.3.0" from the root project
4:29:10 PM: npm ERR!   peer eslint@"*" from @typescript-eslint/experimental-utils@1.13.0
4:29:10 PM: npm ERR!   node_modules/@typescript-eslint/experimental-utils
4:29:10 PM: npm ERR!     @typescript-eslint/experimental-utils@"1.13.0" from @typescript-eslint/parser@1.13.0
4:29:10 PM: npm ERR!     node_modules/@typescript-eslint/parser
4:29:10 PM: npm ERR!       @typescript-eslint/parser@"^1.10.2" from prettier-eslint@9.0.2
4:29:10 PM: npm ERR!       node_modules/prettier-eslint
4:29:10 PM: npm ERR!         prettier-eslint@"^9.0.0" from prettier-eslint-cli@5.0.1
4:29:10 PM: npm ERR!         node_modules/prettier-eslint-cli
4:29:10 PM: npm ERR!   8 more (babel-eslint, eslint-plugin-es, eslint-plugin-import, ...)
4:29:10 PM: npm ERR!
4:29:10 PM: npm ERR! Could not resolve dependency:
4:29:10 PM: npm ERR! peer eslint@"^7.12.1" from eslint-config-standard@16.0.3
4:29:10 PM: npm ERR! node_modules/eslint-config-standard
4:29:10 PM: npm ERR!   dev eslint-config-standard@"^16.0.3" from the root project
4:29:10 PM: npm ERR!
4:29:10 PM: npm ERR! Conflicting peer dependency: eslint@7.32.0
4:29:10 PM: npm ERR! node_modules/eslint
4:29:10 PM: npm ERR!   peer eslint@"^7.12.1" from eslint-config-standard@16.0.3
4:29:10 PM: npm ERR!   node_modules/eslint-config-standard
4:29:10 PM: npm ERR!     dev eslint-config-standard@"^16.0.3" from the root project
4:29:10 PM: npm ERR!
4:29:10 PM: npm ERR! Fix the upstream dependency conflict, or retry
4:29:10 PM: npm ERR! this command with --force, or --legacy-peer-deps
4:29:10 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
4:29:10 PM: npm ERR!
4:29:10 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
4:29:10 PM: npm ERR! A complete log of this run can be found in:
4:29:10 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-10T15_29_08_398Z-debug-0.log
4:29:10 PM: lerna ERR! npm ci exited 1 in 'sanity-gatsby-portfolio-studio'
4:29:10 PM: lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately.
4:29:10 PM: npm ERR! code 1
4:29:10 PM: npm ERR! path /opt/build/repo
4:29:10 PM: npm ERR! command failed
4:29:10 PM: npm ERR! command sh -c lerna bootstrap
4:29:10 PM: npm ERR! A complete log of this run can be found in:
4:29:10 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-10T15_28_59_209Z-debug-0.log
4:29:10 PM: Error during NPM install
4:29:10 PM: Build was terminated: Build script returned non-zero exit code: 1
4:29:10 PM: Failing build: Failed to build site
4:29:10 PM: Finished processing build request in 20.31931606s

My issue I think has been solved by setting NODE_VERSION and matching it to my local node version. I checked it using NVM and then set an environment variable on Netlify for both my Sanity studio repo and the Gatsby web repo.

1 Like

Is anyone still having issues with this? I’m having trouble building without clearing my cache and redeploying.

I have ENV vars for NODE_VERSION, NPM_FLAGS and NPM_VERSION
They match my local version.

The first error is this with the full log below:

1:27:19 PM: npm ERR! code ERESOLVE
1:27:19 PM: npm ERR! ERESOLVE could not resolve
1:27:19 PM: npm ERR!
1:27:19 PM: npm ERR! While resolving: eslint-config-standard@16.0.3
1:27:19 PM: npm ERR! Found: eslint@8.8.0

Full Log:

1:26:49 PM: Build ready to start
1:26:51 PM: build-image version: 0e2f4c52031ab562db66aec633308326e3b108d0 (focal)
1:26:51 PM: build-image tag: focal
1:26:51 PM: buildbot version: 667117c26805e29113bede4ca1afe54070a4e3b1
1:26:51 PM: Fetching cached dependencies
1:26:51 PM: Starting to download cache of 578.4MB
1:26:55 PM: Finished downloading cache in 4.511307623s
1:26:55 PM: Starting to extract cache
1:26:58 PM: Finished extracting cache in 3.150731749s
1:26:58 PM: Finished fetching cache in 7.79885156s
1:26:58 PM: Starting to prepare the repo for build
1:26:59 PM: Preparing Git Reference refs/heads/main
1:27:01 PM: Parsing package.json dependencies
1:27:02 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
1:27:02 PM: Starting build script
1:27:02 PM: Installing dependencies
1:27:02 PM: Python version set to 2.7
1:27:02 PM: Started restoring cached node version
1:27:04 PM: Finished restoring cached node version
1:27:04 PM: v14.18.1 is already installed.
1:27:05 PM: Now using node v14.18.1 (npm v8.13.2)
1:27:05 PM: Started restoring cached build plugins
1:27:05 PM: Finished restoring cached build plugins
1:27:05 PM: Attempting ruby version 2.7.2, read from environment
1:27:06 PM: Using ruby version 2.7.2
1:27:06 PM: Using PHP version 8.0
1:27:07 PM: No npm workspaces detected
1:27:07 PM: Started restoring cached node modules
1:27:07 PM: Finished restoring cached node modules
1:27:07 PM: Started restoring cached go cache
1:27:07 PM: Finished restoring cached go cache
1:27:07 PM: Installing Go version 1.17 (requested 1.17)
1:27:13 PM: unset GOOS;
1:27:13 PM: unset GOARCH;
1:27:13 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
1:27:13 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
1:27:13 PM: go version >&2;
1:27:13 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
1:27:13 PM: go version go1.17 linux/amd64
1:27:13 PM: Installing missing commands
1:27:13 PM: Verify run directory
1:27:15 PM: ​
1:27:15 PM: ────────────────────────────────────────────────────────────────
1:27:15 PM:   Netlify Build                                                 
1:27:15 PM: ────────────────────────────────────────────────────────────────
1:27:15 PM: ​
1:27:15 PM: ❯ Version
1:27:15 PM:   @netlify/build 27.4.2
1:27:15 PM: ​
1:27:15 PM: ❯ Flags
1:27:15 PM:   baseRelDir: true
1:27:15 PM:   buildId: 62d98c5963a49c13eadee8fb
1:27:15 PM:   deployId: 62d98c5963a49c13eadee8fd
1:27:15 PM: ​
1:27:15 PM: ❯ Current directory
1:27:15 PM:   /opt/build/repo
1:27:15 PM: ​
1:27:15 PM: ❯ Config file
1:27:15 PM:   No config file was defined: using default values.
1:27:15 PM: ​
1:27:15 PM: ❯ Context
1:27:15 PM:   production
1:27:15 PM: ​
1:27:15 PM: ────────────────────────────────────────────────────────────────
1:27:15 PM:   1. Build command from Netlify app                             
1:27:15 PM: ────────────────────────────────────────────────────────────────
1:27:15 PM: ​
1:27:15 PM: $ npm run build-web
1:27:15 PM: > ainc-gatsby-sanity@0.0.0 build-web
1:27:15 PM: > lerna bootstrap && (cd studio && SANITY_AUTH_TOKEN=$SANITY_DEPLOY_STUDIO_TOKEN npm run graphql-deploy) && (cd web && npm run build)
1:27:15 PM: lerna notice cli v4.0.0
1:27:15 PM: lerna info ci enabled
1:27:16 PM: lerna info Bootstrapping 2 packages
1:27:16 PM: lerna info Installing external dependencies
1:27:19 PM: lerna ERR! npm ci exited 1 in 'ainc-gatsby-sanity-studio'
1:27:19 PM: lerna ERR! npm ci stderr:
1:27:19 PM: npm WARN ERESOLVE overriding peer dependency
1:27:19 PM: npm WARN While resolving: @hot-loader/react-dom@16.14.0+4.13.0
1:27:19 PM: npm WARN Found: react@17.0.2
1:27:19 PM: npm WARN node_modules/react
1:27:19 PM: npm WARN   react@"^17.0.2" from the root project
1:27:19 PM: npm WARN   41 more (@reach/auto-id, @reach/utils, @sanity/base, ...)
1:27:19 PM: npm WARN
1:27:19 PM: npm WARN Could not resolve dependency:
1:27:19 PM: npm WARN peer react@"^16.14.0" from @hot-loader/react-dom@16.14.0+4.13.0
1:27:19 PM: npm WARN node_modules/@hot-loader/react-dom
1:27:19 PM: npm WARN   @hot-loader/react-dom@"^16.9.0-4.12.11" from @sanity/server@2.25.0
1:27:19 PM: npm WARN   node_modules/@sanity/server
1:27:19 PM: npm WARN
1:27:19 PM: npm WARN Conflicting peer dependency: react@16.14.0
1:27:19 PM: npm WARN node_modules/react
1:27:19 PM: npm WARN   peer react@"^16.14.0" from @hot-loader/react-dom@16.14.0+4.13.0
1:27:19 PM: npm WARN   node_modules/@hot-loader/react-dom
1:27:19 PM: npm WARN     @hot-loader/react-dom@"^16.9.0-4.12.11" from @sanity/server@2.25.0
1:27:19 PM: npm WARN     node_modules/@sanity/server
1:27:19 PM: npm WARN ERESOLVE overriding peer dependency
1:27:19 PM: npm WARN While resolving: @typescript-eslint/parser@1.13.0
1:27:19 PM: npm WARN Found: eslint@8.8.0
1:27:19 PM: npm WARN node_modules/eslint
1:27:19 PM: npm WARN   dev eslint@"^8.3.0" from the root project
1:27:19 PM: npm WARN   9 more (@typescript-eslint/experimental-utils, babel-eslint, ...)
1:27:19 PM: npm WARN
1:27:19 PM: npm WARN Could not resolve dependency:
1:27:19 PM: npm WARN peer eslint@"^5.0.0" from @typescript-eslint/parser@1.13.0
1:27:19 PM: npm WARN node_modules/@typescript-eslint/parser
1:27:19 PM: npm WARN   @typescript-eslint/parser@"^1.10.2" from prettier-eslint@9.0.2
1:27:19 PM: npm WARN   node_modules/prettier-eslint
1:27:19 PM: npm WARN
1:27:19 PM: npm WARN Conflicting peer dependency: eslint@5.16.0
1:27:19 PM: npm WARN node_modules/eslint
1:27:19 PM: npm WARN   peer eslint@"^5.0.0" from @typescript-eslint/parser@1.13.0
1:27:19 PM: npm WARN   node_modules/@typescript-eslint/parser
1:27:19 PM: npm WARN     @typescript-eslint/parser@"^1.10.2" from prettier-eslint@9.0.2
1:27:19 PM: npm WARN     node_modules/prettier-eslint
1:27:19 PM: npm ERR! code ERESOLVE
1:27:19 PM: npm ERR! ERESOLVE could not resolve
1:27:19 PM: npm ERR!
1:27:19 PM: npm ERR! While resolving: eslint-config-standard@16.0.3
1:27:19 PM: npm ERR! Found: eslint@8.8.0
1:27:19 PM: npm ERR! node_modules/eslint
1:27:19 PM: npm ERR!   dev eslint@"^8.3.0" from the root project
1:27:19 PM: npm ERR!   peer eslint@"*" from @typescript-eslint/experimental-utils@1.13.0
1:27:19 PM: npm ERR!   node_modules/@typescript-eslint/experimental-utils
1:27:19 PM: npm ERR!     @typescript-eslint/experimental-utils@"1.13.0" from @typescript-eslint/parser@1.13.0
1:27:19 PM: npm ERR!     node_modules/@typescript-eslint/parser
1:27:19 PM: npm ERR!       @typescript-eslint/parser@"^1.10.2" from prettier-eslint@9.0.2
1:27:19 PM: npm ERR!       node_modules/prettier-eslint
1:27:19 PM: npm ERR!         prettier-eslint@"^9.0.0" from prettier-eslint-cli@5.0.1
1:27:19 PM: npm ERR!         node_modules/prettier-eslint-cli
1:27:19 PM: npm ERR!   8 more (babel-eslint, eslint-plugin-es, eslint-plugin-import, ...)
1:27:19 PM: npm ERR!
1:27:19 PM: npm ERR! Could not resolve dependency:
1:27:19 PM: npm ERR! peer eslint@"^7.12.1" from eslint-config-standard@16.0.3
1:27:19 PM: npm ERR! node_modules/eslint-config-standard
1:27:19 PM: npm ERR!   dev eslint-config-standard@"^16.0.3" from the root project
1:27:19 PM: npm ERR!
1:27:19 PM: npm ERR! Conflicting peer dependency: eslint@7.32.0
1:27:19 PM: npm ERR! node_modules/eslint
1:27:19 PM: npm ERR!   peer eslint@"^7.12.1" from eslint-config-standard@16.0.3
1:27:19 PM: npm ERR!   node_modules/eslint-config-standard
1:27:19 PM: npm ERR!     dev eslint-config-standard@"^16.0.3" from the root project
1:27:19 PM: npm ERR!
1:27:19 PM: npm ERR! Fix the upstream dependency conflict, or retry
1:27:19 PM: npm ERR! this command with --force, or --legacy-peer-deps
1:27:19 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
1:27:19 PM: npm ERR!
1:27:19 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
1:27:19 PM: npm ERR! A complete log of this run can be found in:
1:27:19 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-07-21T17_27_16_860Z-debug-0.log
1:27:19 PM: lerna ERR! npm ci exited 1 in 'ainc-gatsby-sanity-studio'
1:27:19 PM: lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately.
1:27:19 PM: ​
1:27:19 PM: ────────────────────────────────────────────────────────────────
1:27:19 PM:   "build.command" failed                                        
1:27:19 PM: ────────────────────────────────────────────────────────────────
1:27:19 PM: ​
1:27:19 PM:   Error message
1:27:19 PM:   Command failed with exit code 1: npm run build-web (https://ntl.fyi/exit-code-1)
1:27:19 PM: ​
1:27:19 PM:   Error location
1:27:19 PM:   In Build command from Netlify app:
1:27:19 PM:   npm run build-web
1:27:19 PM: ​
1:27:19 PM:   Resolved config
1:27:19 PM:   build:
1:27:19 PM:     base: /opt/build/repo
1:27:19 PM:     command: npm run build-web
1:27:19 PM:     commandOrigin: ui
1:27:19 PM:     environment:
1:27:19 PM:       - NODE_VERSION
1:27:19 PM:       - NPM_FLAGS
1:27:19 PM:       - NPM_VERSION
1:27:19 PM:       - SANITY_DEPLOY_STUDIO_TOKEN
1:27:19 PM:     publish: /opt/build/repo/web/public
1:27:19 PM:     publishOrigin: ui
1:27:19 PM: Caching artifacts
1:27:19 PM: Started saving node modules
1:27:19 PM: Finished saving node modules
1:27:19 PM: Started saving build plugins
1:27:19 PM: Finished saving build plugins
1:27:19 PM: Started saving pip cache
1:27:19 PM: Finished saving pip cache
1:27:19 PM: Started saving emacs cask dependencies
1:27:19 PM: Finished saving emacs cask dependencies
1:27:19 PM: Started saving maven dependencies
1:27:19 PM: Finished saving maven dependencies
1:27:19 PM: Started saving boot dependencies
1:27:19 PM: Finished saving boot dependencies
1:27:19 PM: Started saving rust rustup cache
1:27:19 PM: Finished saving rust rustup cache
1:27:19 PM: Started saving go dependencies
1:27:19 PM: Finished saving go dependencies
1:27:19 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:27:20 PM: Creating deploy upload records
1:27:20 PM: Failing build: Failed to build site
1:27:20 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:27:20 PM: Finished processing build request in 29.336337105s

Try: