The command grunt imagemin
output the following to a random file.
Fatal error: ENOENT, no such file or directory 'app/public/assets/img/epg/recordseries.png'
What's funny is that each time I run the command grunt imagemin again, it manages to process a few more files and ends by outputting the same error about another file.
I'm using
node v0.10.24
npm 1.3.21
grunt@0.4.2
grunt-contrib-imagemin@0.5.0 node_modules/grunt-contrib-imagemin
+-- filesize@2.0.0
+-- async@0.2.9
+-- chalk@0.4.0 (has-color@0.1.2, ansi-styles@1.0.0, strip-ansi@0.1.1)
+-- image-min@0.1.2 (mkdirp@0.3.5, cache-file@0.1.2, mout@0.7.1, optipng-bin@0.3.1, jpegtran-bin@0.2.3, gifsicle@0.1.4)
Here is my grunt config for imagemin
task:
grunt.config('imagemin', {
options: {
optimizationLevel: 3, // 0 to 7, default =7)
// pngquant: true
},
dynamic: { // Multiple target
files: [{
expand: true, // Enable dynamic expansion
cwd: '<%= context.source %>/assets/img/', // equal to app/wesource/assets/img/
src: ['!**/*-'+arrayToRegexStr(platformIgnoreList)+'**', '**/*.{png,jpg,jpeg,gif}'], // Actual patterns to match //
dest: '<%= context.public %>/assets/img/' // equal to app/public/assets/img/
}]
}
});
Uninstalling version 0.5.0 and going back to version 0.3.0 with the following commands should restore the prior functionality:
npm uninstall grunt-contrib-imagemin
npm install --save-dev grunt-contrib-imagemin@0.3.0
There is an issue, https://github.com/gruntjs/grunt-contrib-imagemin/issues/140 , that is being worked on, and when it is fixed it should be safe to upgrade.
The following solutions works on...
This is a hack of a solution, but I found the task fails when it looks at the the target directory to see if the PNG image already exists and is optimized. The task would consistently finish when I ran it over and over, each time it would complete a few more images. And I could repeat the problem by running grunt clean
, then grunt imagemin
over and over.
The error I saw was:
bash Fatal error: ENOENT, no such file or directory 'build-production/path-to/some-image.png'
Copy the images to the target dir immediately before optimizing them. This way, the check passes and unoptimized images that are copied are replaced by their optimized equivalent.
grunt.task.run(
'copy:imagemin',
'imagemin'
);
copy: {
imagemin: {
files: [{
expand: true,
cwd: '<%= exponential.client.src %>',
src: ['images/**/*.{png,jpg,gif}'],
dest: '<%= exponential.client.buildProduction %>'
}]
}
}
imagemin: {
buildProduction: {
files: [{
expand: true,
cwd: '<%= exponential.client.src %>',
src: ['images/**/*.{png,jpg,gif}'],
dest: '<%= exponential.client.buildProduction %>'
}]
}
}
Try to use cache: false
worked for me.
我能够通过卸载我在系统范围内意外安装的optipng
来解决问题。
I had the same issue with grunt-contrib-imagemin and it was because I was running grunt with sudo.
My fix was to do a chown and a chmod on the entire structure then run grunt without sudo...
什么对我有用的是一个干净的安装节点模块我删除了node_modules目录并做了npm安装后,它再次为我工作
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.