How to install libpng-dev on windows?

22,023

Solution 1

I have had similar problem of missing libpng-dev when installing gulp-imagemin under Windows. I found out that libpng-dev does not exist for Windows, only for MacOS and Linux. Here is the error message I have got:

enter > node lib/install.js
  ‼ Request to https://raw.github.com/imagemin/pngquant-bin/v3.0.0/vendor/win/pngquant.exe failed
  ‼ pngquant pre-build test failed
  i compiling from source
  × Error: pngquant failed to build, make sure that libpng-dev is installed
at ChildProcess.exithandler (child_process.js:744:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1008:16)
at Socket.<anonymous> (child_process.js:1176:11)
at Socket.emit (events.js:107:17)
at Pipe.close (net.js:476:12)

So, I have tried to install pngquant-bin with

npm install --save-dev pngquant-bin

but got more or less the same error message. Notice the version number 3.0.0. Then I tried to install pngquant (without -dev) like this:

npm install --save-dev pngquant --msvs_version=2013

and it successfully installed pngquant version 2.0.0. After that I could also install gulp-imagemin.

I am not sure though if the 2013 library version has played any role here.

Solution 2

Use Windows Power Shell, as an Admin, and npm install --global --production windows-build-tools

If you had previous made any npm installation attempt - which you must certainly had, to be reading theses lines right now - you have to clean everything, and do a fresh dependency intsllation:
$ rm node_modules -R
$ rm package-lock.json
$ npm install

Good luck!

Share:
22,023

Related videos on Youtube

Rich
Author by

Rich

Web Designer working in Melbourne.

Updated on July 14, 2022

Comments

  • Rich
    Rich almost 2 years

    I am trying to install the imagemin-pngquant module for node :

    https://www.npmjs.org/package/imagemin-pngquant

    However, when I run the command

    npm install imagemin-pngquant --save-dev
    

    I get the below error:

      warn : pngquant pre-build test failed
      info : compiling from source
     error : Error: pngquant failed to build, make sure that libpng-dev is installed
     at ChildProcess.exithandler (child_process.js:637:15)
     at ChildProcess.EventEmitter.emit (events.js:98:17)
     at maybeClose (child_process.js:735:16)
     at Socket.<anonymous> (child_process.js:948:11)
     at Socket.EventEmitter.emit (events.js:95:17)
     at Pipe.close (net.js:466:12)
    

    How can I install the libpng-dev library that pngquant requires?

  • Madrus
    Madrus about 9 years
    Just wanted to add that using C++ runtime libraries on Windows sometimes is the only way to install nodejs components. One such component is e.g. browser-sync. Of course, you need to have those libraries installed on your machine. Fortunately, installing the free Visual Studio 2013 Community Edition is enough.
  • emeraldjava
    emeraldjava over 4 years
    I had to use '--msvs_version=2017' but using this flag worked for me.
  • Derek Jin
    Derek Jin almost 4 years
    I tried with both 2015 and 2013, but none is worked.