node -v
): 9.6.1npm -v
): 5.6.0Since 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
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.
@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:
@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 :
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
run npm install --save-exact [email protected].* in your web root.
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.
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