Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install is broken by pngquant-bin dependency #46

Open
anthonyaam opened this issue Mar 16, 2018 · 62 comments · Fixed by alibaba/ice#1477
Open

npm install is broken by pngquant-bin dependency #46

anthonyaam opened this issue Mar 16, 2018 · 62 comments · Fixed by alibaba/ice#1477

Comments

@anthonyaam
Copy link

npm install fails with pngquant failed to build, make sure that libpng is installed.

This pngquant-bin issue describes the problem in the pngquant-bin dependency.

@rogerluiz
Copy link

rogerluiz commented Mar 27, 2018

i have de same problem

@tuananh
Copy link

tuananh commented Apr 9, 2018

It still fails for me with version 5.0.1. I have to add this line to my Dockerfile

apt-get install libpng-dev -y --no-install-recommends

What's the last known good version of this library?

@tyler36
Copy link

tyler36 commented May 17, 2018

Same problem on Win10

@ArnisLielturks
Copy link

ArnisLielturks commented May 23, 2018

Faced the same issue.
Fixed by using older imagemin-pngquan and pngquant-bin library versions

npm install [email protected] --save
npm install [email protected] --save```

@ghost
Copy link

ghost commented Jun 13, 2018

npm i -D [email protected]
Fixed the issue, with 4 moderate severity vulnerabilities...

@alex-mitchem
Copy link

alex-mitchem commented Jun 19, 2018

The upgrade from 5.0.1 to 5.1.0 should have been a major version increase, not a minor. webpack-image-loader specifies ^5.0.0 as its dependency, meaning you need to manually edit the npm or yarn lock file to avoid this issue. A major version increment would avoid this issue.

@evinkuraga
Copy link

On a fresh laravel Install, I am getting these problems. Tried series of recommendations:

tried :
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

tried:
npm install cross-env

tried:
npm install [email protected] --save
npm install [email protected] --save

tried switching
cross-env NODE_ENV=
to
node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=

Nothing worked... I'm out of options. Anyone else managed to get passed this?
Again, this is a FRESH install.

@alex-mitchem
Copy link

Just realised I'm one of those terrible people who posts a problem online but never posts the solution.

I fixed this issue using yarn by adding the following to my package.json
"resolutions": {
"image-webpack-loader/imagemin-pngquant": "5.0.1"
}

@evinkuraga
Copy link

evinkuraga commented Jul 26, 2018

@NewDiogenes Ahh.. the smallest glimmer of hope.
Still getting this:

`> npm run development -- --watch

npm WARN invalid config loglevel="notice"

> @ development C:\Users\myuser\Code\laravel_fresh_test
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"

module.js:549
    throw err;
    ^

Error: Cannot find module 'C:\Users\myuser\Code\laravel_fresh_test\node_modules\laravel-mix\setup\webpack.config.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at requireConfig (C:\Users\myuser\Code\laravel_fresh_test\node_modules\webpack\bin\convert-argv.js:97:18)
    at C:\Users\myuser\Code\laravel_fresh_test\node_modules\webpack\bin\convert-argv.js:104:17
    at Array.forEach (<anonymous>)
    at module.exports (C:\Users\myuser\Code\laravel_fresh_test\node_modules\webpack\bin\convert-argv.js:102:15)
    at yargs.parse (C:\Users\myuser\Code\laravel_fresh_test\node_modules\webpack\bin\webpack.js:171:41)
    at Object.Yargs.self.parse (C:\Users\myuser\Code\laravel_fresh_test\node_modules\yargs\yargs.js:533:18)`

Any help GREATLY appreciated!

@alex-mitchem
Copy link

Looks to me that the path to webpack.config.js is incorrect. I would recommend you not use the config file of a dependency like that, but instead copy it across into you project root. Otherwise, double check that the file actually exists at that path.

@evinkuraga
Copy link

evinkuraga commented Jul 27, 2018

For those like me who struggled with this even after trying all the solutions recommended, here is what I did to finally get it to work for me.

I deleted the node_modules folder (rm -rf node_modules)
I rebooted my computer
I disabled my Anti-virus
I compared my package.json to a fresh install and removed any packages that I thought might of caused issue
I ran npm install

Then it worked. Ultimately, I think the culprit might of been my anti-virus (Kaspersky). It's caused some issues before with some packages, which if really is a hassle, because when ever you run npm install / update, npm gives you an ok status even though some files might failed.

@NewDiogenes Thanks for your help! Wasn't the actual problem, but it's appreciated anyways!

@HassanNemir
Copy link

in my case, the error happened because I was using ubuntu 18 and I was trying to run react-boilerplate, so at first the error was the image-webpack-loader, I have tried to install its dependencies and to match the versions and using older versions, but it was solved when I have installed libpng-dev on ubuntu
sudo apt-get install libpng-dev
then I have tried the steps of installing boilerplate in a new repo and now it works.

@pmbuban
Copy link

pmbuban commented Oct 15, 2018

Just realised I'm one of those terrible people who posts a problem online but never posts the solution.

I fixed this issue using yarn by adding the following to my package.json
"resolutions": {
"image-webpack-loader/imagemin-pngquant": "5.0.1"
}

Thanks @NewDiogenes! This is the only solution that worked for me and I've been trying to fix it for a few hours now 😢

@adsingh14
Copy link

adsingh14 commented Oct 16, 2018

Faced the same issue.
Fixed by using older imagemin-pngquan and pngquant-bin library versions

npm install [email protected] --save
npm install [email protected] --save```

Only this single line worked:
npm install [email protected] --save

[OS: Windows]

@stanma
Copy link

stanma commented Oct 22, 2018

To get this fixed I had to install libpng-devel, automake, libtool, autoconf. Then I got it compiled successfully.

Maybe it will help somebody.

@Ke100n4ik
Copy link

Ke100n4ik commented Oct 30, 2018

To get this fixed I had to install libpng-devel, automake, libtool, autoconf. Then I got it compiled successfully.

It works for me, thanks!
Little fix:
libpng-dev, not libpng-devel

@stanma
Copy link

stanma commented Oct 31, 2018

@Ke100n4ik it is devel in Redhat/Fedora Linux. In Ubuntu/Debian it is dev.

@germn
Copy link

germn commented Nov 4, 2018

For me on Windows it was Kaspersky all along (thanks, evinkuraga).
Disabling anti-virus fixed everything without any additional actions.

@bugleev
Copy link

bugleev commented Dec 12, 2018

Tried every suggestion above, but none worked. Then I installed Visual C++ Redistributable for Visual Studio 2015 both x86 and x64 packages, and everything worked instantly. Maybe this would help

@HassanNemir
Copy link

@bugleev what OS are you working on?

@tbruckmaier
Copy link

tbruckmaier commented Dec 14, 2018

I just ran into the issue on npm 3.5.2, npm 6.4.1 worked fine. I could solve it for npm 3 with the fix from @adsingh14 .

npm install [email protected] --save

Just make sure the dependency gets added in package.json without the semver range operator, so it should be "imagemin-pngquant": "5.0.1" not "imagemin-pngquant": "^5.0.1" (in that case, 5.1.* would be installed again). Apparently there is a npm --save-exactswitch, but at least in npm3 this does not work.

@samoldenburg
Copy link

I am getting increasingly frustrated by this issue. No matter what I do, this is where I end up:

  ⚠ The `/home/redacted/node_modules/imagemin-pngquant/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
  ✖ Error: pngquant failed to build, make sure that libpng-dev is installed
    at Promise.all.then.arr (/home/redacted/node_modules/bin-build/node_modules/execa/index.js:231:11)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

We're on RHEL 7.6

  • Tried with Node 6, 8, 10, 11 (latest minor versions)
  • Tried these in various combinations with npm 3.10.10 and 6.5.0
  • libpng-devel is installed
  • make, gcc are installed
  • I have tried locking imagemin-pngquant to 5.0.1, and pngquant-bin to 3.1.1

Is there anything I'm missing?

@techouse
Copy link

Make sure you have all the prerequisites installed
sudo apt install -y build-essential libpng-dev

@MartinCerny-awin
Copy link

I found my solution for alpine in imagemin/pngquant-bin#78 There are many more other solutions. Have a look there if nothing from here works for you.

@alijmlzd
Copy link

I finally fixed this issue by just installing these packages:
apt install bash gcc make libpng-dev

@chpio
Copy link

chpio commented Mar 27, 2020

why not use a precompiled wasm variant of pngquant?

@HydraOrc
Copy link

HydraOrc commented Apr 1, 2020

On Ubuntu you can try to fix it with apt-get install -y libpango1.0-dev command, worked for older node v6

@benjaminpreiss
Copy link

Had the same issue. After trying all of the above answers without success I deleted node_modules folder and installed everything from the beginning:

rm -r node_modules
npm install

@mcljs
Copy link

mcljs commented May 21, 2020

Por favor alguna solución para Windows!!! Gracias! He intentado todos los metodos y nada que funciona todavia

@Qudusayo
Copy link

For Window:OS, install the pngquant command line tool : Link Here, and add the path to your Enviroment Variable, then try Install again

@SONIC3D
Copy link

SONIC3D commented Jun 4, 2020

For Windows OS users:

  • When you install pngquant-bin through npm. (e.g: npm install [email protected]), The post-install step defined in package.json will try to download the pre-built binary from https://raw.githubusercontent.com/imagemin/pngquant-bin/v6.0.0/vendor/win/pngquant.exe. And test running it with pngquant.exe --version to check if the return code is zero. If it failed to get zero return, the 'build from source' phase would be triggered.

  • For most users, using the pre-built binary is the expected way. But there are 2 common problems that would lead you into 'building from source' phase:

    1. Failed to resolve the domain name raw.githubusercontent.com which is commonly caused by DNS pollution.
    2. Lack of corresponding Visual C++ runtime library that pngquant.exe depends on. (For example, [email protected] relies on VCRUNTIME140.dll.) If you don't have the proper VC runtime library installed on your Windows OS, the post-install process would be failed in test running the downloaded binary, but it will directly catch the error and you won't see any error message box pop-up. The post-install logic then turns to build from source in the error-catch procedure.
  • To solve the problems:

    1. Add the correct IP for raw.githubusercontent.com in the dnsmasq config file on your router or local HOST file in your Windows OS.
    2. Download and install all latest VC runtime library here: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

@Pines-Cheng
Copy link

Pines-Cheng commented Jul 3, 2020

I meet this problem when I run npm install --no-bin-links, and npm install is fine, Did the results have any relation?

@the-main-thing
Copy link

On MacOS brew install pkg-config helps. https://stackoverflow.com/questions/62816316/gatsby-new-fails-with-pngquant-related-error

@kuleyu
Copy link

kuleyu commented Jul 22, 2020

For Windows OS users:

  • When you install pngquant-bin through npm. (e.g: npm install [email protected]), The post-install step defined in package.json will try to download the pre-built binary from https://raw.githubusercontent.com/imagemin/pngquant-bin/v6.0.0/vendor/win/pngquant.exe. And test running it with pngquant.exe --version to check if the return code is zero. If it failed to get zero return, the 'build from source' phase would be triggered.

  • For most users, using the pre-built binary is the expected way. But there are 2 common problems that would lead you into 'building from source' phase:

    1. Failed to resolve the domain name raw.githubusercontent.com which is commonly caused by DNS pollution.
    2. Lack of corresponding Visual C++ runtime library that pngquant.exe depends on. (For example, [email protected] relies on VCRUNTIME140.dll.) If you don't have the proper VC runtime library installed on your Windows OS, the post-install process would be failed in test running the downloaded binary, but it will directly catch the error and you won't see any error message box pop-up. The post-install logic then turns to build from source in the error-catch procedure.
  • To solve the problems:

    1. Add the correct IP for raw.githubusercontent.com in the dnsmasq config file on your router or local HOST file in your Windows OS.
    2. Download and install all latest VC runtime library here: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

"Add the correct IP for raw.githubusercontent.com in the dnsmasq config file on your router or local HOST file in your Windows OS." --- Thanks @SONIC3D , this worked for me.

Remarks:

To test whether it is the first reason, we could ping raw.githubusercontent.com in CMD. If true, we can get the correct IP here: https://githubusercontent.com.ipaddress.com/raw.githubusercontent.com

beatrizsmerino added a commit to beatrizsmerino/task-runners that referenced this issue Aug 18, 2020
- Error: You must install additional module [npm install pngquant-bin --save]!
Fixed bug. In windows [email protected] not working, use [email protected]

imagemin/imagemin-pngquant#46
beatrizsmerino added a commit to beatrizsmerino/task-runners that referenced this issue Aug 19, 2020
…nd Ubuntu

- Windows: You must install additional module [npm install pngquant-bin --save]!  It does not work properly on some OS! If you will get an error try use other module.
Fixed bug. In windows [email protected] not working, use [email protected]

- Ubuntu: Error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory.
Not fixed bug.  Not found and cannot install it.

Link issues comments:
imagemin/imagemin-pngquant#46
@littlee
Copy link

littlee commented Sep 12, 2020

I've faced the same issue for a long time. raw.githubusercontent.com is DNS polluted in my area.

I finally fork imagemin-* repos to create some mirror packages

install deps

npm i -D imagemin-pngquant-mirror

change require path

const imagemin = require('imagemin');
const pngquant = require('imagemin-pngquant-mirror');

life gets easier from now on 👯‍♂️

@huangsiyuan2015
Copy link

For Windows OS users:

  • When you install pngquant-bin through npm. (e.g: npm install [email protected]), The post-install step defined in package.json will try to download the pre-built binary from https://raw.githubusercontent.com/imagemin/pngquant-bin/v6.0.0/vendor/win/pngquant.exe. And test running it with pngquant.exe --version to check if the return code is zero. If it failed to get zero return, the 'build from source' phase would be triggered.

  • For most users, using the pre-built binary is the expected way. But there are 2 common problems that would lead you into 'building from source' phase:

    1. Failed to resolve the domain name raw.githubusercontent.com which is commonly caused by DNS pollution.
    2. Lack of corresponding Visual C++ runtime library that pngquant.exe depends on. (For example, [email protected] relies on VCRUNTIME140.dll.) If you don't have the proper VC runtime library installed on your Windows OS, the post-install process would be failed in test running the downloaded binary, but it will directly catch the error and you won't see any error message box pop-up. The post-install logic then turns to build from source in the error-catch procedure.
  • To solve the problems:

    1. Add the correct IP for raw.githubusercontent.com in the dnsmasq config file on your router or local HOST file in your Windows OS.
    2. Download and install all latest VC runtime library here: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

Thanks a million! first works for me, I have tried many solutions, took nearly two days on this problem, but none is worked.
this answer saves me, thanks again.

@cizario
Copy link

cizario commented Jan 23, 2021

for Windows users, have a look at this post for in-depth explanation : https://ryanohara.com/2020/fixing-npm-pngquant-failed-to-build-make-sure-that-libpng-dev/

@sluck430
Copy link

For Windows OS users:

  • When you install pngquant-bin through npm. (e.g: npm install [email protected]), The post-install step defined in package.json will try to download the pre-built binary from https://raw.githubusercontent.com/imagemin/pngquant-bin/v6.0.0/vendor/win/pngquant.exe. And test running it with pngquant.exe --version to check if the return code is zero. If it failed to get zero return, the 'build from source' phase would be triggered.

  • For most users, using the pre-built binary is the expected way. But there are 2 common problems that would lead you into 'building from source' phase:

    1. Failed to resolve the domain name raw.githubusercontent.com which is commonly caused by DNS pollution.
    2. Lack of corresponding Visual C++ runtime library that pngquant.exe depends on. (For example, [email protected] relies on VCRUNTIME140.dll.) If you don't have the proper VC runtime library installed on your Windows OS, the post-install process would be failed in test running the downloaded binary, but it will directly catch the error and you won't see any error message box pop-up. The post-install logic then turns to build from source in the error-catch procedure.
  • To solve the problems:

    1. Add the correct IP for raw.githubusercontent.com in the dnsmasq config file on your router or local HOST file in your Windows OS.
    2. Download and install all latest VC runtime library here: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

Thank you, It is useful on my win os! Just two simple steps here:

  1. Edit local dns host file and append raw.githubusercontent.com ip-domain pair;
  2. download 2015-2022 vc and install it;
    Then it is worked! Awesome!

@HduSy
Copy link

HduSy commented Jun 1, 2022

the bin file 'pngquant' in dependency pngquant-bin is not downloaded

@Captain890
Copy link

i solved my issue by using this command -----npm install --global windows-build-tools

@turbodog03
Copy link

For Windows OS users:

* When you install pngquant-bin through npm. (e.g: `npm install [email protected]`), The post-install step defined in package.json will try to download the pre-built binary from `https://raw.githubusercontent.com/imagemin/pngquant-bin/v6.0.0/vendor/win/pngquant.exe`. And test running it with `pngquant.exe --version` to check if the return code is zero. If it failed to get zero return, the 'build from source' phase would be triggered.

* For most users, using the pre-built binary is the expected way. But there are 2 common problems that would lead you into 'building from source' phase:
  
  1. Failed to resolve the domain name `raw.githubusercontent.com` which is commonly caused by DNS pollution.
  2. Lack of corresponding Visual C++ runtime library that `pngquant.exe` depends on. (For example, [email protected] relies on `VCRUNTIME140.dll`.) If you don't have the proper VC runtime library installed on your Windows OS, the post-install process would be failed in test running the downloaded binary, but it will directly catch the error and you won't see any error message box pop-up. The post-install logic then turns to build from source in the error-catch procedure.

* To solve the problems:
  
  1. Add the correct IP for `raw.githubusercontent.com` in the dnsmasq config file on your router or local HOST file in your Windows OS.
  2. Download and install all latest VC runtime library here: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

Thanks a lot! I solved it by

  1. adding the correct IP for ``raw.githubusercontent.com` in the host file
  2. restart the shell.

Thank you again for the detailed answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.