npm install image-webpack-loader error: Error: pngquant failed to build, make sure that libpng-dev is installed

created at 10-17-2021 views: 22

Recap:

When packaging the vue2 project, it was found that the image packaging failed.

Then Google searched for a solution and saw a blog post that was similar to mine, saying that when possible, the loader image-webpack-loader had a problem with the installation, so I tried to uninstall it and reinstall it, and the error occurred! ! !

googled search solution is:

Run the cmd window as an administrator and install windows-build-tools globally, as shown in the figure 

cmd window

After installation, go to install image-webpack-loader, it's really ok! ! !

But I still have a problem here, that is, when I use cnpm to install, I get an error:

Error]: Run "C:\Windows\system32\cmd.exe /d /s /c node lib/install.js" error, exit code 1

This is entered in the terminal integrated with vscode. Google said that it was going to open cmd with administrator privileges and enter the command. After a try, it was indeed installed. Maybe you and I will run into each other in the future, so I'd better record it.

Reverse again. . . The previous problems were indeed encountered, but after cnpm installed the image-weboac-loader, there were still packaging errors and image compression errors. Thought it was resolved.

After several hours of tinkering, on a whim, I executed cnpm update for half a day and then packaged it, but I didn't expect it to succeed. . . It's really twists and turns.

In fact, it has also provided you and me with a solution. Because this is my second deployment and packaged. It was ok on the company's public computer for the first time, but all kinds of failures occurred when I worked on my computer. If you encounter the same problem, you might as well do an update like me. . . Maybe it can be solved. . . 0.0

created at:10-17-2021
edited at: 10-17-2021: