this is a gruntfile.json
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
imagemin: {
options: {
optimizationLevel: 3,
flatten: true ,
cache: false
},
build: {
expand: true,
cwd: 'public/images',
src: ['**/*.{png,jpg,gif}'],
dest: 'images/min'
}
}
});
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.registerTask('default', ['imagemin']);
};
我得到了这个错误
致命错误:此套接字已关闭。
这是一个完整的错误详细信息
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Registering "grunt-contrib-imagemin" local Npm module tasks.
Reading C:UsersMohamedDesktopegwebstormnode_modulesgrunt-contrib-imageminpackage.json...OK
Parsing C:UsersMohamedDesktopegwebstormnode_modulesgrunt-contrib-imageminpackage.json...OK
Loading "imagemin.js" tasks...OK
+ imagemin
Loading "Gruntfile.js" tasks...OK
+ default
No tasks specified, running default tasks.
Running tasks: default
Running "default" task
Running "imagemin" task
Running "imagemin:build" (imagemin) task
Verifying property imagemin.build exists in config...OK
Files: public/images/facebook.png -> images/min/facebook.png
---- the list of other images -----
Options: interlaced, optimizationLevel=3, progressive, flatten, cache=false
Fatal error: This socket is closed.
并且没有创建图像文件夹或进行任何更改,我查看了代码,但我不知道是否需要修复
嘗試
重新安裝 imagemin:
npm uninstall grunt-contrib-imagemin
npm install --save-dev grunt-contrib-imagemin