Home
Support Forums

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