Fatal error: this socket is closed when I test grunt-contrib-imagemin

I am testing the grunt-contrib-imagemin plugin for jpg minify. But this always failed because the execution of the "imagemin: dynamic" (imagemin) task fatal error: this connector is closed.

Source : grunt.initConfig({ imagemin: { // Task dynamic: { // Another target files: [{ expand: true, // Enable dynamic expansion cwd: 'src/', // Src matches are relative to this path src: ['**/*.{png,jpg,gif}'], // Actual patterns to match dest: 'dist/' // Destination path prefix }] } } }); 
+5
source share
4 answers

Try reinstalling grunt-contrib-imagemin:

 npm cache clean npm install grunt-contrib-imagemin --save-dev 
+1
source

Problem:

while doing

 npm install 

You will receive an error message:

  ? Request to https://raw.github.com/imagemin/jpegtran-bin/3.0.2/vendor/win/x64/jpegtran.exe failed ? jpegtran pre-build test failed i compiling from source × GotError: Request to http://downloads.sourceforge.net/project/libjpeg-turbo/1.4.0/libjpeg-turbo-1.4.0.tar.gz failed at ClientRequest.<anonymous> (YourApp\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtr n-bin\node_modules\bin-build\node_modules\download\node_modules\got\index.js:177:7) at ClientRequest.g (events.js:199:16) at ClientRequest.emit (events.js:107:17) at Socket.socketErrorListener (_http_client.js:271:9) at Socket.emit (events.js:107:17) at net.js:459:14 at process._tickCallback (node.js:355:11) aused By: Error: read ECONNRESET at exports._errnoException (util.js:746:11) at TCP.onread (net.js:559:26) gifsicle@3.0.1 postinstall YourApp\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle node lib/install.js ? Request to https://raw.github.com/imagemin/gifsicle-bin/3.0.1/vendor/win/x64/gifsicle.exe failed ? gifsicle pre-build test failed i compiling from source × GotError: Request to http://www.lcdf.org/gifsicle/gifsicle-1.87.tar.gz failed at ClientRequest.<anonymous> (YourApp\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsic e\node_modules\bin-build\node_modules\download\node_modules\got\index.js:177:7) at ClientRequest.g (events.js:199:16) at ClientRequest.emit (events.js:107:17) at Socket.socketErrorListener (_http_client.js:271:9) at Socket.emit (events.js:107:17) at net.js:459:14 at process._tickCallback (node.js:355:11) aused By: Error: read ECONNRESET at exports._errnoException (util.js:746:11) at TCP.onread (net.js:559:26) optipng-bin@3.0.2 postinstall YourApp\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-b n node lib/install.js ? Request to https://raw.github.com/imagemin/optipng-bin/3.0.2/vendor/win/optipng.exe failed ? optipng pre-build test failed i compiling from source × GotError: Request to http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.5/optipng-0.7.5.tar.gz failed at ClientRequest.<anonymous> (YourApp\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng bin\node_modules\bin-build\node_modules\download\node_modules\got\index.js:177:7) at ClientRequest.g (events.js:199:16) at ClientRequest.emit (events.js:107:17) at Socket.socketErrorListener (_http_client.js:271:9) at Socket.emit (events.js:107:17) at net.js:459:14 at process._tickCallback (node.js:355:11) aused By: Error: read ECONNRESET at exports._errnoException (util.js:746:11) at TCP.onread (net.js:559:26) 

Cause:

grunt-contrib-imagemin cannot load and test 3 dependencies

imagemin-gifsicle

imagemin-OptiPNG

imagemin-jpegtran

Decision

  • install version of grunt-contrib-imagemin 0.9.4

     npm cache clear npm uninstall grunt-contrib-imagemin npm install --save-dev grunt-contrib-imagemin@.0.9.4 
  • gifsicle

    Download gifsicle.exe 32 bit from here

    unzip it
    make a folder called vendor on yourapp \ node_modules \ grunt-contrib- imagemin \ node_modules \ imagemin \ node_modules \ imagemin-gifsicle \ node_modules \ gifsicle \

    copy the extracted gifsicle.exe file to the provider folder

    You have now fixed the problem with gifsicle. don't leave two more to go :)

  • OptiPNG

    Download optipng.exe from here create a folder called vendor on yourapp \ node_modules \ grunt-contrib-imagemin \ node_modules \ imagemin \ node_modules \ imagemin-optipng \ node_module \ optipng-bin \

    Copy the extracted optipng.exe file here. You have now fixed the optipng problem. don't go out, another one to go :)

  • jpegtran

    Download jpegtran.exe and libjpeg-62.dll place them in the provider folder inside

    yourapp \ node_modules \ grunt-contrib-imagemin \ node_modules \ imagemin \ node_modules \ imagemin-jpegtran \ node_module \ jpegtran-bin \

Hooray, you're done. and yours

  Grunt imagemin:dist 
Command

will be successful

Remember

if you install grunt again, which therefore installs grunt-contrib-imagemin, these folders will not be overwritten. However, for a first and clean installation, you need to go through these steps.

+1
source

I have the same atm problem. I tried an older version and it worked great. There is a problem in the git repository, so you are not alone on this;)

https://github.com/gruntjs/grunt-contrib-imagemin/issues/273

0
source

According to Github ticket # 273: (Fatal error: this socket is closed) it was caused by jpegtran-bin Problem No. 54 . Both released solutions are now resolved and closed.

Installing grunt-contrib-imagemin 0.9.2 solved this for me by running

 npm cache clean npm install grunt-contrib-imagemin --save-dev 
0
source

Source: https://habr.com/ru/post/1205595/


All Articles