nodejs在linux下使用 imagemin imagemin-pngquant(主要是gulp grunt构建中用比较多),出现了 Error: write EPIPE的问题,在ubuntu下没有出现,但是在centos下出现了。 首先在安装的过程中就提示了需要安装 libpng-dev,
`/home/subying/gitlab/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly ⚠ pngquant pre-build test failed ℹ compiling from source ✖ Error: pngquant failed to build, make sure that libpng-dev is installed at ChildProcess.exithandler (child_process.js:202:12) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:850:16) at Socket.(internal/child_process.js:323:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at Pipe._handle.close [as _onclose] (net.js:492:12)
而实际上是安装libpng libpng-devel,执行
yum install libpng libpng-devel
安装完成后,需要安装 ImageMagick GraphicsMagick 这两个图像处理的软件 安装 ImageMagick 直接使用命令就可以了
yum install ImageMagick
但是安装GraphicsMagick相对比较麻烦,先要下载
wget -O GraphicsMagick-1.3.24.tar.gz https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.24/GraphicsMagick-1.3.24.tar.gz/download
接着解压
tar zvxf GraphicsMagick-1.3.24.tar.gz
到文件里
cd GraphicsMagick-1.3.24
接下来就是安装了
./configure
sudo make
sudo make install
安装完之后重启电脑,就不会出现这个问题了
吐槽一下,新版的这个代码显示真心丑.....