gulp-imagemin: ERROR getting "optipng ENOENT" in ttf2woff2
Hi all! I am using gulp-imageming for almost a year now. Recently after running npm install
to update all modules I am getting and ENOENT error strangely in ttf2woff2
plugin. I have no idea how is this plugin connected to gulp-images or optipng.
Do you have any ideas what to try? Thank you.
I am runnigng this:
gulpImagemin({ optimizationLevel: 4, svgoPlugins: [ {removeViewBox: false} ] })
I am getting this error:
/XY/node_modules/ttf2woff2/jssrc/ttf2woff2.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["re
Error: spawn /XY/node_modules/optipng-bin/vendor/optipng ENOENT
at exports._errnoException (util.js:856:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:475:9)
at process._tickCallback (node.js:389:17)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 15
Commits related to this issue
- change dev dependencies https://github.com/sindresorhus/gulp-imagemin/issues/236#issuecomment-292611025 — committed to tagip/grunt-builder by mikaoelitiana 7 years ago
- Add prebuild script to fix issues w/ imagemin deps Not sure why, but `jpegtran` and `optipng` don't seem to install correctly when doing a fresh install. Manually running their post-install scripts s... — committed to xaviervalarino/portfolio by xaviervalarino 3 years ago
- Add prebuild script to fix issues w/ imagemin deps Not sure why, but `jpegtran` and `optipng` don't seem to install correctly when doing a fresh install. Manually running their post-install scripts s... — committed to xaviervalarino/portfolio by xaviervalarino 3 years ago
Hi all, on my case. I have just run manually the post-install script and it magically works
node node_modules/optipng-bin/lib/install.js
TL;DR:
Don’t forget to install this package on your system (for me, an alpine linux):
I test also to install it and I have the error on alpine docker. So steps are:
Many errors appear and indicate that on my system it miss :
Then same thing for optipng
It seems it lakes of z-lib so I install it on my alpine image :
And then we re-launch the test
And for the gif optimisation with
gifsicle
We need to install also automake and then:
So, this is the whole installation:
Finally, to compile and install the binaries correctly after this debug session, I full remove
~/.npm cache
andnode_modules
and i lauch anpm install
.I was running into a similar issue when running in a docker alpine container. What fixed for me was adding
gifsicle
,jpegtran-bin
,optipng-bin
, andsvgo
as dependencies as well:Same problem but with pngquant and zopflipng This workaround should work for all this kind of problems:
@sindresorhus There’s a way to fix this behaviour?
Cool…it is just a question of size. Maybe it works greats with Jessie one. Using many Alpine instead of Jessie could save lots of disk space 😉
I found that installing the following packages on Alpine Linux got things building successfully again:
But in the end I switched from running node on Alipine Linux to using one of the official node docker images (
node:8
). These are based on Debian Jessie and gave me none of these problems.All Unix based have to install it, so not bad, I create ASAP a PR for README.
@chadyred I wonder if all of those dependencies should be listed in the readme or wiki?
@ayoubice @sindresorhus Bumped into this again today.
The source of the issue appears to be that the optipng post install script fails to run as it isn’t handling spaces in directory names. Here’s the output on OS X following an
npm install optipng
After that, the optipng pre-build test fails and ugliness follows.
As suggested, running the post-install script manually completes the install and hey presto. I assume this is because the command is properly escaped when run manually.