11ty / eleventy-img

Utility to perform build-time image transformations.

Home Page:https://www.11ty.dev/docs/plugins/image/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugin intermittently fails with ENOENT Error "no such file or error"

stephanmax opened this issue · comments

I am losing my mind 😅 First of all, thank you for this amazing plugin.

I am struggling to present a minimal failing example, because every time I want to preserve the error I am seeing and push a failing example to GitHub, it works again. So I hope that anyone out there can maybe deduct from the symptoms I am seeing, what could be the problem.

I have a very tiny personal website that I wanted to switch from MD + NJK to MD + WebC + Image plugin. Everything worked great for WebC (except some hiccups with permalinks), but the Eleventy image plugin kept failing on me. I implemented an overwrite component for the native <img>, pretty much as presented in Robin’s article Optimize your img tags with Eleventy Image and WebC.

I got his repo to run, I got a minimal example to run, but as soon as I started to add my own images and used either a markdown image or an <img> tag in my WebC or MD files, I got an error like this:

1. Having trouble writing to "_site/notes/index.html" from "./notes/index.webc" (via EleventyTemplateError)
2. ENOENT: no such file or directory, stat '/img/x2wQ-wJ7Wv-300.jpeg' (via Error)

But I can see the images files in _site/img/, the plugin definitely creates the files the error is complaining about. I am using outputDir and urlPath to create the right paths for the images. I tried to circle in on the bug and isolate it, and at some point it just started working out of the blue. I definitely see the correct images sometimes. But then I got the error again with another image in another page.

I have no idea what is going on. I can only dream and hope that this rings a bell for someone out there and that I am missing something tiny and stupid.

Summary:

  • I am using Webc and Markdown with markdownTemplateEngine: "webc"
  • I have the img component in includes/img.webc and registered it with addPlugin of the webc plugin
  • I am not using any passthrough for images, I rely solely on setting the outputPath on the image plugin

Thank you so much in advance for giving this a read! Let me know if I can provide anything else that might be helpful. I will try to create a failing minimal example in the meantime.

Okay, it was a dumb tiny thing on my end: using @html instead of @raw in a template caused another webc run of an already transformed file. Of course the transformed image path was not found. 🤦🏻‍♂️

I’ll see myself out 😅