Gatsby sanity deploy issue

I can run gatsby and sanity locally - no problems
I can run the build command locally - no problems

But when deploying I get the following error:

Error: [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './create-content-dige  st' is not defined by "exports" in /opt/build/repo/aefgatsby/node_modules/gats  by-source-sanity/node_modules/gatsby-core-utils/package.json

Not sure what is causing it and could not find a similar error. I tried changing the node version with a .nvmrc but that did not work

any help/guidance is much appreciated :) 

netlify site name: [staging-aef.netlify.app](https://staging-aef.netlify.app/)

9:16:27 PM: Build ready to start
9:17:09 PM: build-image version: 1ac2360cf8aee6cb2695dd2682b312fefc908a7f
9:17:09 PM: build-image tag: v3.15.0
9:17:09 PM: buildbot version: fe6512288e75c8fa5aadaebb51ed1f96e9314fd4
9:17:09 PM: Fetching cached dependencies
9:17:09 PM: Starting to download cache of 166.6MB
9:17:11 PM: Finished downloading cache in 1.933559441s
9:17:11 PM: Starting to extract cache
9:17:13 PM: Finished extracting cache in 1.856493993s
9:17:13 PM: Finished fetching cache in 3.87393992s
9:17:13 PM: Starting to prepare the repo for build
9:17:14 PM: Preparing Git Reference refs/heads/main
9:17:14 PM: Parsing package.json dependencies
9:17:15 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'aefgatsby/public' versus 'public' in the Netlify UI
9:17:15 PM: Starting build script
9:17:15 PM: Installing dependencies
9:17:15 PM: Python version set to 2.7
9:17:16 PM: Started restoring cached node version
9:17:17 PM: Finished restoring cached node version
9:17:17 PM: v12.18.0 is already installed.
9:17:18 PM: Now using node v12.18.0 (npm v6.14.4)
9:17:18 PM: Started restoring cached build plugins
9:17:18 PM: Finished restoring cached build plugins
9:17:18 PM: Attempting ruby version 2.7.2, read from environment
9:17:18 PM: Using ruby version 2.7.2
9:17:19 PM: Using PHP version 5.6
9:17:19 PM: No npm workspaces detected
9:17:19 PM: Started restoring cached node modules
9:17:19 PM: Finished restoring cached node modules
9:17:19 PM: Installing NPM modules using NPM version 6.14.4
9:17:37 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!
9:17:37 PM: > msgpackr-extract@2.1.2 install /opt/build/repo/aefgatsby/node_modules/msgpackr-extract
9:17:37 PM: > node-gyp-build-optional-packages
9:17:37 PM: > lmdb@2.5.3 install /opt/build/repo/aefgatsby/node_modules/lmdb
9:17:37 PM: > node-gyp-build-optional-packages
9:17:37 PM: > sharp@0.30.7 install /opt/build/repo/aefgatsby/node_modules/gatsby-sharp/node_modules/sharp
9:17:37 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
9:17:38 PM: sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.12.2/libvips-8.12.2-linux-x64.tar.br
9:17:39 PM: sharp: Integrity check passed for linux-x64
9:17:39 PM: > core-js@3.24.1 postinstall /opt/build/repo/aefgatsby/node_modules/core-js
9:17:39 PM: > node -e "try{require('./postinstall')}catch(e){}"
9:17:39 PM: > core-js-pure@3.24.1 postinstall /opt/build/repo/aefgatsby/node_modules/core-js-pure
9:17:39 PM: > node -e "try{require('./postinstall')}catch(e){}"
9:17:39 PM: > es5-ext@0.10.62 postinstall /opt/build/repo/aefgatsby/node_modules/es5-ext
9:17:39 PM: >  node -e "try{require('./_postinstall')}catch(e){}" || exit 0
9:17:39 PM: > styled-components@5.3.5 postinstall /opt/build/repo/aefgatsby/node_modules/styled-components
9:17:39 PM: > node ./postinstall.js
9:17:40 PM: npm WARN acorn-import-assertions@1.8.0 requires a peer of acorn@^8 but none is installed. You must install peer dependencies yourself.
9:17:40 PM: npm WARN gatsby-plugin-image@1.14.2 requires a peer of gatsby-source-filesystem@^3.0.0-next.0 but none is installed. You must install peer dependencies yourself.
9:17:40 PM: npm WARN ts-node@9.1.1 requires a peer of typescript@>=2.7 but none is installed. You must install peer dependencies yourself.
9:17:40 PM: npm WARN tsutils@3.21.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-win32-x64@2.1.2 (node_modules/@msgpackr-extract/msgpackr-extract-win32-x64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-win32-x64@2.1.2: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-linux-arm64@2.1.2 (node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-linux-arm64@2.1.2: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-linux-arm@2.1.2 (node_modules/@msgpackr-extract/msgpackr-extract-linux-arm):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-linux-arm@2.1.2: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-darwin-arm64@2.1.2 (node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-darwin-arm64@2.1.2: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-darwin-x64@2.1.2 (node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-darwin-x64@2.1.2: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-win32-x64@2.5.3 (node_modules/@lmdb/lmdb-win32-x64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-win32-x64@2.5.3: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-linux-arm64@2.5.3 (node_modules/@lmdb/lmdb-linux-arm64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-linux-arm64@2.5.3: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-darwin-x64@2.5.3 (node_modules/@lmdb/lmdb-darwin-x64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-darwin-x64@2.5.3: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-linux-arm@2.5.3 (node_modules/@lmdb/lmdb-linux-arm):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-linux-arm@2.5.3: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-darwin-arm64@2.5.3 (node_modules/@lmdb/lmdb-darwin-arm64):
9:17:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-darwin-arm64@2.5.3: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
9:17:40 PM: added 104 packages from 296 contributors, removed 31 packages, updated 366 packages and audited 2049 packages in 20.361s
9:17:41 PM: 327 packages are looking for funding
9:17:41 PM:   run `npm fund` for details
9:17:41 PM: found 25 vulnerabilities (11 moderate, 12 high, 2 critical)
9:17:41 PM:   run `npm audit fix` to fix them, or `npm audit` for details
9:17:41 PM: NPM modules installed
9:17:41 PM: Started restoring cached go cache
9:17:41 PM: Finished restoring cached go cache
9:17:41 PM: go version go1.14.4 linux/amd64
9:17:41 PM: go version go1.14.4 linux/amd64
9:17:41 PM: Installing missing commands
9:17:41 PM: Verify run directory
9:17:42 PM: ​
9:17:42 PM: ────────────────────────────────────────────────────────────────
9:17:42 PM:   Netlify Build                                                 
9:17:42 PM: ────────────────────────────────────────────────────────────────
9:17:42 PM: ​
9:17:42 PM: ❯ Version
9:17:42 PM:   @netlify/build 27.9.1
9:17:42 PM: ​
9:17:42 PM: ❯ Flags
9:17:42 PM:   baseRelDir: true
9:17:42 PM:   buildId: 62ec291b84989e0009c84f5c
9:17:42 PM:   deployId: 62ec291b84989e0009c84f5e
9:17:42 PM:   systemLogFile: 3
9:17:42 PM: ​
9:17:42 PM: ❯ Current directory
9:17:42 PM:   /opt/build/repo/aefgatsby
9:17:42 PM: ​
9:17:42 PM: ❯ Config file
9:17:42 PM:   No config file was defined: using default values.
9:17:42 PM: ​
9:17:42 PM: ❯ Context
9:17:42 PM:   production
9:17:42 PM: ​
9:17:42 PM: ────────────────────────────────────────────────────────────────
9:17:42 PM:   1. Build command from Netlify app                             
9:17:42 PM: ────────────────────────────────────────────────────────────────
9:17:42 PM: ​
9:17:42 PM: $ npm run build
9:17:42 PM: > aef-website@0.1.0 build /opt/build/repo/aefgatsby
9:17:42 PM: > gatsby build
9:17:44 PM: error Error in "/opt/build/repo/aefgatsby/node_modules/gatsby-source-sanity/gatsby-node.js": Package subpath './create-content-digest' is not defined by "exports" in /opt/build/repo/aefgatsby/node_modules/gatsby-source-sanity/node_modules/gatsby-core-utils/package.json
9:17:44 PM: 
9:17:44 PM: 
9:17:44 PM:   Error: [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './create-content-dige  st' is not defined by "exports" in /opt/build/repo/aefgatsby/node_modules/gats  by-source-sanity/node_modules/gatsby-core-utils/package.json
9:17:44 PM:   
9:17:44 PM:   - loader.js:491 applyExports
9:17:44 PM:     internal/modules/cjs/loader.js:491:9
9:17:44 PM:   
9:17:44 PM:   - loader.js:507 resolveExports
9:17:44 PM:     internal/modules/cjs/loader.js:507:23
9:17:44 PM:   
9:17:44 PM:   - loader.js:635 Function.Module._findPath
9:17:44 PM:     internal/modules/cjs/loader.js:635:31
9:17:44 PM:   
9:17:44 PM:   - loader.js:953 Function.Module._resolveFilename
9:17:44 PM:     internal/modules/cjs/loader.js:953:27
9:17:44 PM:   
9:17:44 PM:   - loader.js:842 Function.Module._load
9:17:44 PM:     internal/modules/cjs/loader.js:842:27
9:17:44 PM:   
9:17:44 PM:   - loader.js:1026 Module.require
9:17:44 PM:     internal/modules/cjs/loader.js:1026:19
9:17:44 PM:   
9:17:44 PM:   - v8-compile-cache.js:159 require
9:17:44 PM:     [aefgatsby]/[v8-compile-cache]/v8-compile-cache.js:159:20
9:17:44 PM:   
9:17:44 PM:   - url-generator.js:12 Object.<anonymous>
9:17:44 PM:     [aefgatsby]/[gatsby-source-sanity]/[gatsby-plugin-utils]/dist/polyfill-remot    e-file/utils/url-generator.js:12:28
9:17:44 PM:   
9:17:44 PM:   - v8-compile-cache.js:192 Module._compile
9:17:44 PM:     [aefgatsby]/[v8-compile-cache]/v8-compile-cache.js:192:30
9:17:44 PM:   
9:17:44 PM:   - loader.js:1158 Object.Module._extensions..js
9:17:44 PM:     internal/modules/cjs/loader.js:1158:10
9:17:44 PM:   
9:17:44 PM:   - loader.js:986 Module.load
9:17:44 PM:     internal/modules/cjs/loader.js:986:32
9:17:44 PM:   
9:17:44 PM:   - loader.js:879 Function.Module._load
9:17:44 PM:     internal/modules/cjs/loader.js:879:14
9:17:44 PM:   
9:17:44 PM:   - loader.js:1026 Module.require
9:17:44 PM:     internal/modules/cjs/loader.js:1026:19
9:17:44 PM:   
9:17:44 PM:   - v8-compile-cache.js:159 require
9:17:44 PM:     [aefgatsby]/[v8-compile-cache]/v8-compile-cache.js:159:20
9:17:44 PM:   
9:17:44 PM:   - public-url-resolver.js:7 Object.<anonymous>
9:17:44 PM:     [aefgatsby]/[gatsby-source-sanity]/[gatsby-plugin-utils]/dist/polyfill-remot    e-file/graphql/public-url-resolver.js:7:21
9:17:44 PM:   
9:17:44 PM:   - v8-compile-cache.js:192 Module._compile
9:17:44 PM:     [aefgatsby]/[v8-compile-cache]/v8-compile-cache.js:192:30
9:17:44 PM:   
9:17:44 PM: 
9:17:44 PM: not finished open and validate gatsby-configs, load plugins - 0.451s
9:17:44 PM: npm ERR! code ELIFECYCLE
9:17:44 PM: npm ERR! errno 1
9:17:44 PM: npm ERR! aef-website@0.1.0 build: `gatsby build`
9:17:44 PM: npm ERR! Exit status 1
9:17:44 PM: npm ERR!
9:17:44 PM: npm ERR! Failed at the aef-website@0.1.0 build script.
9:17:44 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
9:17:44 PM: npm ERR! A complete log of this run can be found in:
9:17:44 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-08-04T20_17_44_620Z-debug.log
9:17:44 PM: ​
9:17:44 PM: ────────────────────────────────────────────────────────────────
9:17:44 PM:   "build.command" failed                                        
9:17:44 PM: ────────────────────────────────────────────────────────────────
9:17:44 PM: ​
9:17:44 PM:   Error message
9:17:44 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
9:17:44 PM: ​
9:17:44 PM:   Error location
9:17:44 PM:   In Build command from Netlify app:
9:17:44 PM:   npm run build
9:17:44 PM: ​
9:17:44 PM:   Resolved config
9:17:44 PM:   build:
9:17:44 PM:     base: /opt/build/repo/aefgatsby
9:17:44 PM:     command: npm run build
9:17:44 PM:     commandOrigin: ui
9:17:44 PM:     environment:
9:17:44 PM:       - BLOGGER_BLOG_API_KEY
9:17:44 PM:       - BLOGGER_BLOG_ID
9:17:44 PM:       - GATSBY_PAGE_SIZE
9:17:44 PM:       - SANITY_PROJECT_ID
9:17:44 PM:       - SANITY_TOKEN
9:17:44 PM:       - SENTRY_DSN
9:17:44 PM:     publish: /opt/build/repo/aefgatsby/public
9:17:44 PM:     publishOrigin: ui
9:17:45 PM: Caching artifacts
9:17:45 PM: Started saving node modules
9:17:45 PM: Finished saving node modules
9:17:45 PM: Started saving build plugins
9:17:45 PM: Finished saving build plugins
9:17:45 PM: Started saving pip cache
9:17:45 PM: Finished saving pip cache
9:17:45 PM: Started saving emacs cask dependencies
9:17:45 PM: Finished saving emacs cask dependencies
9:17:45 PM: Started saving maven dependencies
9:17:45 PM: Finished saving maven dependencies
9:17:45 PM: Started saving boot dependencies
9:17:45 PM: Finished saving boot dependencies
9:17:45 PM: Started saving rust rustup cache
9:17:45 PM: Finished saving rust rustup cache
9:17:45 PM: Started saving go dependencies
9:17:45 PM: Finished saving go dependencies
9:17:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:17:45 PM: Creating deploy upload records
9:17:45 PM: Failing build: Failed to build site
9:17:45 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:17:45 PM: Finished processing build request in 35.79657835s

fixed - i added a .nvmrc in the gatsby folder with this inside

16.0.0

and that did the trick

Thanks so much for coming back and letting us know! We are so glad you found a solution. Happy building :rocket: