Error: ENOENT: no such file or directory, open '/opt/build/repo/web/node_modul es/gatsby-source-sanity/src/gatsby-node.ts'

Having trouble to pass my build. Not sure what it could be. I have tried a few things that I found on the forums, like CI= npm run build, clearing cache, rebuilding, updating dependencies, would be very happy to get this up!

Netlify site: https://idlehours-midway.netlify.app/

Build settings:

Log below:


8:35:39 PM: Build ready to start
8:35:41 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
8:35:41 PM: build-image tag: v3.4.1
8:35:41 PM: buildbot version: e1f4178b0d9779ebad1b11d5b54739f82fed3c22
8:35:41 PM: Fetching cached dependencies
8:35:41 PM: Starting to download cache of 2.0MB
8:35:41 PM: Finished downloading cache in 163.152296ms
8:35:41 PM: Starting to extract cache
8:35:41 PM: Finished extracting cache in 40.03306ms
8:35:41 PM: Finished fetching cache in 204.241556ms
8:35:41 PM: Starting to prepare the repo for build
8:35:41 PM: Preparing Git Reference refs/heads/master
8:35:43 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'web/public' versus 'public' in the Netlify UI
8:35:43 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'web/functions' versus '' in the Netlify UI
8:35:43 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'gatsby build && netlify-lambda build src/lambda' versus 'npm run build' in the Netlify UI
8:35:43 PM: Starting build script
8:35:43 PM: Installing dependencies
8:35:43 PM: Python version set to 2.7
8:35:44 PM: v12.18.0 is already installed.
8:35:45 PM: Now using node v12.18.0 (npm v6.14.4)
8:35:45 PM: Started restoring cached build plugins
8:35:45 PM: Finished restoring cached build plugins
8:35:45 PM: Attempting ruby version 2.7.1, read from environment
8:35:46 PM: Using ruby version 2.7.1
8:35:47 PM: Using PHP version 5.6
8:35:47 PM: 5.2 is already installed.
8:35:47 PM: Using Swift version 5.2
8:35:47 PM: Started restoring cached node modules
8:35:47 PM: Finished restoring cached node modules
8:35:47 PM: Started restoring cached yarn cache
8:35:47 PM: Finished restoring cached yarn cache
8:35:47 PM: Installing yarn at version 1.22.4
8:35:47 PM: Installing Yarn!
8:35:47 PM: > Downloading tarball...
8:35:47 PM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.PU0NPQ9Quu
8:35:47 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
8:35:47 PM:                                  Dload  Upload   Total   Spent    Left  Speed
8:35:47 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
8:35:47 PM: 100    80  100    80    0     0    258      0 --:--:-- --:--:-- --:--:--   258
8:35:47 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
8:35:47 PM: 100    93  100    93    0     0    149      0 --:--:-- --:--:-- --:--:--   367
8:35:48 PM: 100   643  100   643    0     0    733      0 --:--:-- --:--:-- --:--:--   733
8:35:48 PM: 100 1215k  100 1215k    0     0   937k      0  0:00:01  0:00:01 --:--:--  937k
8:35:48 PM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.PU0NPQ9Quu.asc
8:35:48 PM: 100    84  100    84    0     0   3043      0 --:--:-- --:--:-- --:--:--  3043
8:35:48 PM: 100    97  100    97    0     0   1707      0 --:--:-- --:--:-- --:--:--  1707
8:35:48 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
8:35:48 PM: 100   647  100   647    0     0   7237      0 --:--:-- --:--:-- --:--:--  631k
8:35:48 PM: 100  1028  100  1028    0     0   7928      0 --:--:-- --:--:-- --:--:--  7928
8:35:48 PM: > Verifying integrity...
8:35:48 PM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
8:35:48 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
8:35:48 PM: gpg: WARNING: This key is not certified with a trusted signature!
8:35:48 PM: gpg:          There is no indication that the signature belongs to the owner.
8:35:48 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
8:35:48 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
8:35:48 PM: > GPG signature looks good
8:35:48 PM: > Extracting to ~/.yarn...
8:35:48 PM: > Adding to $PATH...
8:35:49 PM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
8:35:49 PM: Installing NPM modules using Yarn version 1.22.4
8:35:49 PM: yarn install v1.22.4
8:35:49 PM: [1/4] Resolving packages...
8:35:51 PM: [2/4] Fetching packages...
8:35:59 PM: warning url-loader@1.1.2: Invalid bin field for "url-loader".
8:36:27 PM: info fsevents@2.1.3: The platform "linux" is incompatible with this module.
8:36:27 PM: info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
8:36:27 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
8:36:27 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
8:36:27 PM: [3/4] Linking dependencies...
8:36:27 PM: warning "docz > gatsby-plugin-eslint@2.0.8" has unmet peer dependency "eslint@^6.6.0".
8:36:27 PM: warning "docz > gatsby-plugin-eslint@2.0.8" has unmet peer dependency "eslint-loader@^3.0.2".
8:36:27 PM: warning "docz > gatsby > @pmmmwh/react-refresh-webpack-plugin@0.4.2" has incorrect peer dependency "react-refresh@^0.8.3".
8:36:27 PM: warning " > gatsby-link@2.4.13" has unmet peer dependency "@reach/router@^1.3.3".
8:36:27 PM: warning "docz > gatsby-theme-docz > gatsby-plugin-emotion@4.3.10" has unmet peer dependency "@babel/core@^7.0.0".
8:36:27 PM: warning "docz > gatsby-theme-docz > gatsby-plugin-emotion > @emotion/babel-preset-css-prop@10.0.27" has unmet peer dependency "@babel/core@^7.0.0".
8:36:27 PM: warning "docz > gatsby > gatsby-cli > gatsby-recipes > gatsby-interface@0.0.166" has incorrect peer dependency "gatsby@2.6.0".
8:36:27 PM: warning "docz > gatsby > gatsby-cli > gatsby-recipes > gatsby-interface@0.0.166" has incorrect peer dependency "react@16.8.1".
8:36:27 PM: warning "docz > gatsby > gatsby-cli > gatsby-recipes > gatsby-interface@0.0.166" has incorrect peer dependency "react-dom@16.8.1".
8:36:27 PM: warning "docz > gatsby-theme-docz > gatsby-plugin-emotion > @emotion/babel-preset-css-prop > @emotion/babel-plugin-jsx-pragmatic@0.1.5" has unmet peer dependency "@babel/core@^7.0.0".
8:36:27 PM: warning "gatsby-plugin-sass > sass-loader@7.3.1" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
8:36:27 PM: warning " > gatsby-react-router-scroll@2.3.1" has unmet peer dependency "@reach/router@^1.0".
8:36:27 PM: warning " > react-loads@9.2.4" has unmet peer dependency "@types/react@>=16.8.0".
8:36:27 PM: warning " > shopify-storefront-api-typings@1.2.1" has unmet peer dependency "graphql@>=14".
8:36:27 PM: warning " > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
8:36:27 PM: warning " > ts-jest@24.3.0" has unmet peer dependency "jest@>=24 <25".
8:36:52 PM: [4/4] Building fresh packages...
8:37:04 PM: success Saved lockfile.
8:37:04 PM: Done in 74.80s.
8:37:04 PM: NPM modules installed using Yarn
8:37:04 PM: Started restoring cached go cache
8:37:04 PM: Finished restoring cached go cache
8:37:05 PM: go version go1.14.4 linux/amd64
8:37:05 PM: go version go1.14.4 linux/amd64
8:37:05 PM: Installing missing commands
8:37:05 PM: Verify run directory
8:37:06 PM: ​
8:37:06 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
8:37:06 PM: β”‚        Netlify Build        β”‚
8:37:06 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
8:37:06 PM: ​
8:37:06 PM: ❯ Version
8:37:06 PM:   @netlify/build 3.3.5
8:37:06 PM: ​
8:37:06 PM: ❯ Flags
8:37:06 PM:   deployId: 5f567d7be700eed0715ea2db
8:37:06 PM:   mode: buildbot
8:37:06 PM: ​
8:37:06 PM: ❯ Current directory
8:37:06 PM:   /opt/build/repo/web
8:37:06 PM: ​
8:37:06 PM: ❯ Config file
8:37:06 PM:   /opt/build/repo/web/netlify.toml
8:37:06 PM: ​
8:37:06 PM: ❯ Context
8:37:06 PM:   production
8:37:07 PM: ​
8:37:07 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
8:37:07 PM: β”‚ 1. build.command from netlify.toml β”‚
8:37:07 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
8:37:07 PM: ​
8:37:07 PM: $ gatsby build && netlify-lambda build src/lambda
8:37:10 PM: success open and validate gatsby-configs - 0.404s
8:37:11 PM: success load plugins - 0.911s
8:37:11 PM: success onPreInit - 0.046s
8:37:11 PM: success delete html and css files from previous builds - 0.003s
8:37:11 PM: info One or more of your plugins have changed since the last time you ran Gatsby. As
8:37:11 PM: a precaution, we're deleting your site's cache to ensure there's no stale data.success initialize cache - 0.052s
8:37:11 PM: success copy gatsby files - 0.052s
8:37:11 PM: error UNHANDLED REJECTION ENOENT: no such file or directory, open '/opt/build/repo/web/node_modules/gatsby-source-sanity/src/gatsby-node.ts'
8:37:11 PM: 
8:37:11 PM: 
8:37:11 PM:   Error: ENOENT: no such file or directory, open '/opt/build/repo/web/node_modul  es/gatsby-source-sanity/src/gatsby-node.ts'
8:37:11 PM:   
8:37:11 PM:   - api-runner-node.js:458 
8:37:11 PM:     [web]/[gatsby]/src/utils/api-runner-node.js:458:27
8:37:11 PM:   
8:37:11 PM:   - util.js:16 tryCatcher
8:37:11 PM:     [web]/[bluebird]/js/release/util.js:16:23
8:37:11 PM:   
8:37:11 PM:   - promise.js:547 Promise._settlePromiseFromHandler
8:37:11 PM:     [web]/[bluebird]/js/release/promise.js:547:31
8:37:11 PM:   
8:37:11 PM:   - promise.js:604 Promise._settlePromise
8:37:11 PM:     [web]/[bluebird]/js/release/promise.js:604:18
8:37:11 PM:   
8:37:11 PM:   - promise.js:649 Promise._settlePromise0
8:37:11 PM:     [web]/[bluebird]/js/release/promise.js:649:10
8:37:11 PM:   
8:37:11 PM:   - promise.js:725 Promise._settlePromises
8:37:11 PM:     [web]/[bluebird]/js/release/promise.js:725:18
8:37:11 PM:   
8:37:11 PM:   - async.js:93 _drainQueueStep
8:37:11 PM:     [web]/[bluebird]/js/release/async.js:93:12
8:37:11 PM:   
8:37:11 PM:   - async.js:86 _drainQueue
8:37:11 PM:     [web]/[bluebird]/js/release/async.js:86:9
8:37:11 PM:   
8:37:11 PM:   - async.js:102 Async._drainQueues
8:37:11 PM:     [web]/[bluebird]/js/release/async.js:102:5
8:37:11 PM:   
8:37:11 PM:   - async.js:15 Immediate.Async.drainQueues [as _onImmediate]
8:37:11 PM:     [web]/[bluebird]/js/release/async.js:15:14
8:37:11 PM:   
8:37:11 PM:   - timers.js:456 processImmediate
8:37:11 PM:     internal/timers.js:456:21
8:37:11 PM:   
8:37:11 PM: 
8:37:11 PM: not finished onPreBootstrap - 0.062s
8:37:12 PM: ​
8:37:12 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
8:37:12 PM: β”‚   "build.command" failed    β”‚
8:37:12 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
8:37:12 PM: ​
8:37:12 PM:   Error message
8:37:12 PM:   Command failed with exit code 1: gatsby build && netlify-lambda build src/lambda
8:37:12 PM: ​
8:37:12 PM:   Error location
8:37:12 PM:   In build.command from netlify.toml:
8:37:12 PM:   gatsby build && netlify-lambda build src/lambda
8:37:12 PM: ​
8:37:12 PM:   Resolved config
8:37:12 PM:   build:
8:37:12 PM:     base: /opt/build/repo/web
8:37:12 PM:     command: gatsby build && netlify-lambda build src/lambda
8:37:12 PM:     commandOrigin: config
8:37:12 PM:     environment:
8:37:12 PM:       - TYPE
8:37:12 PM:     functions: /opt/build/repo/web/functions
8:37:12 PM:     publish: /opt/build/repo/web/public
8:37:12 PM: Caching artifacts
8:37:12 PM: Started saving node modules
8:37:12 PM: Finished saving node modules
8:37:12 PM: Started saving build plugins
8:37:12 PM: Finished saving build plugins
8:37:12 PM: Started saving yarn cache
8:37:12 PM: Finished saving yarn cache
8:37:12 PM: Started saving pip cache
8:37:12 PM: Finished saving pip cache
8:37:12 PM: Started saving emacs cask dependencies
8:37:12 PM: Finished saving emacs cask dependencies
8:37:12 PM: Started saving maven dependencies
8:37:12 PM: Finished saving maven dependencies
8:37:12 PM: Started saving boot dependencies
8:37:12 PM: Finished saving boot dependencies
8:37:12 PM: Started saving go dependencies
8:37:12 PM: Finished saving go dependencies
8:37:15 PM: Error running command: Build script returned non-zero exit code: 1
8:37:15 PM: Failing build: Failed to build site
8:37:15 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
8:37:15 PM: Finished processing build request in 1m34.02409051s

hey there,

8:37:11 PM: info One or more of your plugins have changed since the last time you ran Gatsby. As
8:37:11 PM: a precaution, we're deleting your site's cache to ensure there's no stale data.success initialize cache - 0.052s
8:37:11 PM: success copy gatsby files - 0.052s
8:37:11 PM: error UNHANDLED REJECTION ENOENT: no such file or directory, open '/opt/build/repo/web/node_modules/gatsby-source-sanity/src/gatsby-node.ts'
8:37:11 PM: 
8:37:11 PM: 
8:37:11 PM:   Error: ENOENT: no such file or directory, open '/opt/build/repo/web/node_modul  es/gatsby-source-sanity/src/gatsby-node.ts'
8:37:11 PM:   

the problem is definitely in here somewhere - i am wondering if a package has changed and you have the latest versions.

does this run locally?

Thank you for checking into it.

Yes it runs locally.

I have run npm install would the move be to individual update packages?

Hi, @acaplan58, the repo is public so I tested the build local and I get the same error:

$ npm run build

> midway@0.1.0 build /Users/luke/tmp/idletime_09_midway/web
> gatsby build

success open and validate gatsby-configs - 0.269s
success load plugins - 2.079s
success onPreInit - 0.035s
success delete html and css files from previous builds - 0.004s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 0.064s
success copy gatsby files - 0.048s

 ERROR

UNHANDLED REJECTION ENOENT: no such file or directory, open '/Users/luke/tmp/idletime_09_midway/web/node_modules/gatsby-source-sanity/src/gatsby-node.ts'

12:41:37 AM: Installing NPM modules using Yarn version 1.22.4

12:41:37 AM: yarn install v1.22.4

12:41:38 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
``
  Error: ENOENT: no such file or directory, open '/Users/luke/tmp/idletime_09_midway/web/node_modules/gatsby-source-sanity/src/gatsby-node.ts'

I suspect the issue is that npm and yarn are being mixed as mentioned in the logs:

12:41:37 AM: Installing NPM modules using Yarn version 1.22.4
12:41:37 AM: yarn install v1.22.4
12:41:38 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.

To clarify, this issue happens with a fresh clone of the repo so it is not caused by Netlify. Please resolve the issue with the repo itself and when that is resolve we can troubleshoot if it still isn’t working at Netlify.

This is all I did to reproduce the error locally:

git clone https://github.com/accaplan/idletime_09_midway
cd idletime_09_midway/web
yarn install
npm run build

Again, this repo is mixing Yarn and NPM together and that isn’t recommended or supported by either package manager. I would start with fixing that issue and proceeding from there.

I just ran into this same issue today.

Came across this closed issue in the gatsby-source-sanity Github Issues

Not sure if this helps any but I’m trying what they’re suggesting out. Will let you know if it works

@acaplan58 So I resolved that main issue. It looks like in web/gatsby-config.js the environment variables were returning undefined. Looks like you have to set them either in netlify.toml or within the Netlify settings Build & Deploy > Environment.

Not sure if this resolves your issue, but it resolved it in my case.

I reinstalled and redeployed making sure to only use npm. Oddly my template guide used yarn and npm run build. However it still failed until I add the environment variables in Netlify UI!!! Would like to figure out how to get this through my git bucket but for now very happy to have it working. THANK YOU!!

1 Like

@acaplan58 Glad that did the trick! Yeah it took me a bit to debug but fortunate I came across that Github issue thread.

1 Like