laravel-mix: Cannot deploy my app using laravel-mix since 3 days due to exiting code on pngquant lib

  • Laravel Mix Version: 2.1.1
  • Node Version (node -v): 9.6.1
  • NPM Version (npm -v): 5.6.0
  • OS: Debian

Since 3 days, it’s impossible for me to use Laravel Mix to deploy my application. The problem is that Laravel Mix requires pngquant library and this library has been updated 3 days ago by adding a line to exit the process when an error occurs! It means that all next npm packages cannot be installed. I don’t know if laravel-mix can modify something but the problem is very boring.

Linked to open issue: https://github.com/imagemin/pngquant-bin/issues/78

Here is the stack trace that occurs:

pngquant-bin@4.0.0 postinstall /var/www/palm/20180315202846/node_modules/pngquant-bin

node lib/install.js

⚠ The /var/www/pp/20180315202846/node_modules/pngquant-bin/vendor/pngquant binary doesn't seem to work correctly
⚠ pngquant pre-build test failed
ℹ compiling from source
✔ pngquant pre-build test passed successfully
✖ RequestError: pngquant failed to build, make sure that libpng-dev is installed
at ClientRequest.req.once.err (/var/www/pp/20180315202846/node_modules/pngquant-bin/node_modules/got/index.js:111:21)
at Object.onceWrapper (events.js:272:13)
at ClientRequest.emit (events.js:180:13)
at ClientRequest.onConnect (/var/www/pp/20180315202846/node_modules/pngquant-bin/node_modules/tunnel-agent/index.js:168:23)
at Object.onceWrapper (events.js:272:13)
at ClientRequest.emit (events.js:180:13)
at Socket.socketOnData (_http_client.js:476:11)
at Socket.emit (events.js:180:13)
at addChunk (_stream_readable.js:269:12)
at readableAddChunk (_stream_readable.js:256:11)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pngquant-bin@4.0.0 postinstall: node lib/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pngquant-bin@4.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
^C
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-03-15T20_19_09_479Z-debug.log

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 19

Commits related to this issue

Most upvoted comments

For those having problems with Ubuntu. Try: wget -q -O /tmp/libpng12.deb http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1_amd64.deb
&& sudo dpkg -i /tmp/libpng12.deb
&& rm /tmp/libpng12.deb

The issue comes from new release of imagemin-pngquant v5.1 requires pngquant-bin@4.0.0 The quick fix is to downgrade imagemin-pngquant to 5.0.* which requires pngquant-bin@3.1.1

Run this command and commit your package.json npm install --save-exact imagemin-pngquant@5.0.*

Same issue on alpine. Fixed by installing:

apk add --update \
           bash \ #needs bash.
           libpng-dev \
           gcc \
           g++ \
           make \

I had similar issues, the workaround has been as what I explained in my comment:

I got similiar error for Laravel in Ubuntu 17.10. I used @sory19 method as below: I had the same issue but it is resolved by first installing libpng-dev Need to follow the following steps: sudo apt-get install libpng-dev and then run npm install -g pngquant-bin

Still had same error. This is what I did.

Removed the “node_modules” folder: sudo rm -rf node_modules Re-ran npm install And it worked after that.

Ubuntu 18.04… Had same problem. “Fixed” issue by piecing together some posts from above @softwaredeveloperca and @ngoctp :

  1. run wget -q -O /tmp/libpng12.deb http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1_amd64.deb && sudo dpkg -i /tmp/libpng12.deb && rm /tmp/libpng12.deb

  2. run npm install --save-exact imagemin-pngquant@5.0.* in your web root.

  3. run npm install in your web root.

@btica-ro I think you are my new favourite person - thanks (y)

I was missing g++

Thanks a lot @btica-ro!