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

Created on 18 Mar 2018  Â·  17Comments  Â·  Source: JeffreyWay/laravel-mix

  • 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:

[email protected] 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: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: node lib/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
stale

Most helpful comment

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

All 17 comments

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-devand 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.

@wawanopoulos
From what I have read from here:
https://github.com/imagemin/pngquant-bin/issues/78

It seems to be an issue with the OS that you are using. So far Ubuntu seems to be fine. Only a few other Linux distros seem to have trouble. This might not be a laravel-mix issue.

I will let Jeffer Way to confirm with you on this.

Thanks man @velu76

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

Thank you @softwaredeveloperca I was having trouble in Ubuntu and your instructions have resolved the issues i was having after the NPM update.

The issue comes from new release of imagemin-pngquant v5.1 requires [email protected]
The quick fix is to downgrade imagemin-pngquant to 5.0.* which requires [email protected]

Run this command and commit your package.json
npm install --save-exact [email protected].*

thank you @softwaredeveloperca this is what I was looking for like hell! @wawanopoulos try his solution it will help you to fix it!

Same issue on alpine. Fixed by installing:

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

Thanks a lot @btica-ro!

@wawanopoulos i believe your issue, from following the stack trace, stems from a network call the installer is doing. there are 2 PRs open to try and address this issue.

https://github.com/imagemin/pngquant-bin/pull/80
https://github.com/imagemin/pngquant-bin/pull/83

Thanks @ngoctp about your downgrading tweak.

For those who try to install Laravel spark, here is the workaround:

  • Run spark new install > spark new project_name
  • When you arrive at the "Would you like to install the NPM dependencies?" point, just hang and open a new SSH window
  • Browse into your project_name folder created by spark installer
  • Type > npm install --save-exact [email protected]
  • Go back to your previous SSH window and now type [yes] to install the NPM dependencies
  • Everything should go fine, it do not treat anymore pngquant as it's already inside node_modules folder
  • Finish installation by saying [yes] at the question > ... compile your assets

@Enjoy

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

I was missing g++

Thank you @softwaredeveloperca This fix worked on Debian 9

@ngoctp downgrade tweak did it for me. life saver!

Thanks @softwaredeveloperca! Worked perfectly in Ubuntu 18

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 [email protected].* in your web root.

  3. run npm install in your web root.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kpilard picture kpilard  Â·  3Comments

jpmurray picture jpmurray  Â·  3Comments

sdebacker picture sdebacker  Â·  3Comments

dtheb picture dtheb  Â·  3Comments

amin101 picture amin101  Â·  3Comments