Yarn build:production asset optimizationError: spawn

Using Sage9.

 94% asset optimizationError: spawn /Users/xxxx/Sites/+trellis/xxxx.co.uk/site/web/app/themes/xxxx/node_modules/jpegtran-bin/vendor/jpegtran ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.

I am assuming this is an issue with my images. I only have x2 images in my /resources/assets/images folder:

  • One is used in my scss: background-image: url('../images/hero.jpg');
  • The other is added within a page in admin: <img src="/app/themes/xxxx/dist/images/xxxx.jpg">

Anyone have any ideas what is causing this or where I should start looking?

Many thanks!

1 Like

I had a similar issue and was able to fix it by upgrading to the latest imagemin-mozjpeg package.

4 Likes

Thanks @strarsis, this worked for me.
Well, to be exact, rm -rf node_modules and running yarn again did :sweat_smile:

2 Likes

Side note: I encountered not this same, but a similar issue some days ago where installing imagemin using (latest) npm resuilted in missing build steps and missing mozjpeg binaries while yarn was able to build these binaries correctly. So when you use npm again as it really got much faster now, there are still use cases for yarn, when you have trouble with missing imagemin binaries after installing with npm.