Error: ENOENT: no such file or directory

14
closed
hamiltonbrooke
hamiltonbrooke
Posted 3 months ago

Error: ENOENT: no such file or directory #32288

Preliminary Checks

Description

Been developing a couple of different Gatsby websites over the last few weeks with no issues at all. Both websites source data from WordPress using GraphQL.

Last night I ran npm run develop as usual and now my browser isn't rendering the website and throwing up the following error:

"Loading chunk node_modules_gatsby-plugin-image_dist_lazy-hydrate-9f0721eb_js failed"

My terminal is throwing up the following error:

"Error: ENOENT: no such file or directory, open '/Users/olivermcvey/Gatsby/hamiltonbrooke/.cache/caches/gatsby-plugin-sharp/diskstore-4d952606169b55fb368c7f62f68deb2c.json'"

I've tried running gatsby clean a few times and reinstalling my node_modules folder but no joy.

I'm still finding my way round Gatsby but this issue only occurs on pages with images.

Not sure if the problem lays with:

gatsby-plugin-image, childImageSharp or gatsby-source-wordpress? Screenshot_2021-07-07_at_10 30 23

Reproduction Link

Sorry, no repo to share.

Steps to Reproduce

Expected Result

Website to build and render normally

Actual Result

Website development server fails after visiting localhost

Environment

System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.4.2 - /usr/local/bin/node
    npm: 7.18.1 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 91.0.4472.114
    Firefox: 88.0.1
    Safari: 14.1.1
  npmPackages:
    gatsby: ^3.9.0 => 3.9.0
    gatsby-plugin-emotion: ^6.9.0 => 6.9.0
    gatsby-plugin-image: ^1.9.0 => 1.9.0
    gatsby-plugin-manifest: ^3.9.0 => 3.9.0
    gatsby-plugin-postcss: ^4.9.0 => 4.9.0
    gatsby-plugin-react-helmet: ^4.9.0 => 4.9.0
    gatsby-plugin-sharp: ^3.9.0 => 3.9.0
    gatsby-plugin-sitemap: ^4.5.0 => 4.5.0
    gatsby-source-filesystem: ^3.7.1 => 3.9.0
    gatsby-source-wordpress: ^5.9.0 => 5.9.0
    gatsby-transformer-sharp: ^3.9.0 => 3.9.0

Config Flags

No response

klittlepage
klittlepage
Created 3 months ago

I can confirm this exact issue, which manifested itself when updating from 3.8.0 to 3.9.0 of gatsby-plugin-sharp. As a temporary workaround, forcing a downgrade of gatsby-plugin-sharp from 3.9.0 to 3.8.0 or earlier fixes the issue on my end at least.


  System:
    OS: macOS 11.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.2 - /usr/local/opt/[email protected]/bin/node
    Yarn: 2.4.2 - /usr/local/bin/yarn
    npm: 6.14.13 - /usr/local/opt/[email protected]/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 91.0.4472.114
    Firefox: 89.0.2
    Safari: 14.1.1
  npmPackages:
    gatsby: ^3.9.0 => 3.9.0
    gatsby-plugin-force-trailing-slashes: ^1.0.5 => 1.0.5
    gatsby-plugin-google-gtag: ^3.9.0 => 3.9.0
    gatsby-plugin-image: ^1.9.0 => 1.9.0
    gatsby-plugin-layout: ^2.9.0 => 2.9.0
    gatsby-plugin-manifest: ^3.9.0 => 3.9.0
    gatsby-plugin-material-ui: ^3.0.1 => 3.0.1
    gatsby-plugin-mdx: ^2.9.0 => 2.9.0
    gatsby-plugin-offline: ^4.9.0 => 4.9.0
    gatsby-plugin-react-helmet: ^4.9.0 => 4.9.0
    gatsby-plugin-react-svg: ^3.0.1 => 3.0.1
    gatsby-plugin-robots-txt: ^1.6.8 => 1.6.8
    gatsby-plugin-sharp: 3.8.0 => 3.8.0
    gatsby-plugin-sitemap: ^4.5.0 => 4.5.0
    gatsby-plugin-typescript: ^3.9.0 => 3.9.0
    gatsby-plugin-web-font-loader: ^1.0.4 => 1.0.4
    gatsby-remark-copy-linked-files: ^4.6.0 => 4.6.0
    gatsby-remark-images: ^5.6.0 => 5.6.0
    gatsby-source-filesystem: ^3.9.0 => 3.9.0
    gatsby-transformer-sharp: ^3.9.0 => 3.9.0
    gatsby-transformer-yaml: ^3.9.0 => 3.9.0
hamiltonbrooke
hamiltonbrooke
Created 3 months ago

Thanks so much @klittlepage, downgrading gatsby-plugin-sharp to the previous 3.8.0 version has resolved the issue. Sounds like a bug with 3.9.0 which hopefully will be addressed in the next release.

runemadsen
runemadsen
Created 3 months ago

I am running into the exact same problem: gatsby-plugin-image version 3.9.0 will randomly generate some images but not other, causing the dev server to crash when trying to load the .json cache files:

Error: ENOENT: no such file or directory, open 'GATSBYREPOPATH/.cache/caches/gatsby-plugin-sharp/diskstore-33fef0dc22f08
  97aa1fd038bd02e4ebb.json'

This does not seem to be a problem when running gatsby build. The problem is solved by fixing the package version to 3.8.0.

LekoArts
LekoArts
Created 3 months ago

Hi!

Please provide a minimal reproduction and we'll be able to take a look.

runemadsen
runemadsen
Created 3 months ago

Here's a minimal reproduction with the same setup as the larger website: https://github.com/processing/processing-website/tree/gatsby-plugin-sharp-error

You will see that the images on localhost:8000 are never created and are stuck with the placeholders. The gatsby develop process will break with something like:

Error: ENOENT: no such file or directory, open '/Users/user/processing/processing-website/.cache/caches/gatsby-plugin-sharp/diskstore-ac98ec5946a2b
  4478f8e6797679e67ac.json'

Run the same code with gatsby-plugin-sharp version 3.8.0 and everything will work.

LekoArts
LekoArts
Created 3 months ago

Thanks for that. I'm also seeing this in my test repo: https://github.com/LekoArts/issue-32288

I see two issues:

  1. When editing the query inside the page, e.g. changing the width from 800 to 900 in gatsbyImageData it shows the error overlay and I need to reload the page
  2. When removing the cache and starting up gatsby develop the page shows the placeholder and crashes on the error that the people mentioned

Starting the server again solves it for me. So it only occurred when I used gatsby clean and then gatsby develop.

klittlepage
klittlepage
Created 3 months ago

@LekoArts, how many images/queries are you testing it with? After a gatsby clean and multiple runs of gatsby develop, I'm seeing a seemingly random subset of images loading successfully before the server crashes. This holds for n > 3 static images and roughly ten attempts at running gatsby develop.

I'm only bringing this up if it helps to isolate the issue; using 3.8.0 is probably a better workaround than repeatedly starting the server.

runemadsen
runemadsen
Created 3 months ago

@klittlepage In my repo it crashes when loading 8 images. Haven't tested anything less than that.

pieh
pieh
Created 3 months ago

Hey folks, this seems to be combination of new gatsby and gatsby-plugin-sharp versions introduced in https://github.com/gatsbyjs/gatsby/pull/31901 . https://github.com/gatsbyjs/gatsby/pull/32307 is potential fix.

mbcod3
mbcod3
Created 3 months ago

I am running into the exact same problem: gatsby-plugin-image version 3.9.0 will randomly generate some images but not other, causing the dev server to crash when trying to load the .json cache files:

Error: ENOENT: no such file or directory, open 'GATSBYREPOPATH/.cache/caches/gatsby-plugin-sharp/diskstore-33fef0dc22f08
  97aa1fd038bd02e4ebb.json'

This does not seem to be a problem when running gatsby build. The problem is solved by fixing the package version to 3.8.0.

Actually its not gatsby-plugin-image, its gatsby-plugin-sharp that needs to be downgraded to 3.8.0.

Previous