Skip to content

Instantly share code, notes, and snippets.

@welcoMattic
Last active February 15, 2022 20:58
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save welcoMattic/9f0991fa81a80096a3877ee42562c504 to your computer and use it in GitHub Desktop.
Save welcoMattic/9f0991fa81a80096a3877ee42562c504 to your computer and use it in GitHub Desktop.
How to fix `Error: spawn ./node_modules/jpegtran-bin/vendor/jpegtran ENOENT` error for imagemin

If you're trying to run imagemin (from grunt or gulp or anything else) on Alpine, you certainly had to meet this error :

Error: spawn /YOUR_PROJECT_PATH/node_modules/jpegtran-bin/vendor/jpegtran ENOENT or the same with optipng or gifsicle instead of jpegtran.

Here's how to solve it.

First you need to install on Alpine missing package used to compile jpegtran, gifsicle and optipng binaries. Those packages are (at least):

autoconf automake file build-base nasm musl libpng-dev zlib-dev

Now, rebuild your container.

And then, remove your node_module directory, and run npm install or yarn command.

Enjoy 🎉

Note: this workaround works like a charm for me, please comment here if your meet other issues ;)

@SiavashEXE
Copy link

Hi,

I solved the issue with the command below:
npm rebuild jpegtran-bin

Thanks man! it worked perfectly!

@fintinc
Copy link

fintinc commented Feb 15, 2022

npm rebuild jpegtran-bin

Works – Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment