由于imagemin问题,Grunt构build失败,出了什么问题?

我正在尝试使用grunt build构build一个应用程序,我得到这个错误:

 # grunt build Running "clean:dist" (clean) task Running "wiredep:app" (wiredep) task Running "wiredep:sass" (wiredep) task Running "includeSource:dist" (includeSource) task File "dist/index.html" created. Running "useminPrepare:html" (useminPrepare) task Configuration changed for concat, uglify, cssmin Running "concurrent:dist" (concurrent) task >> Warning: There are more tasks than your concurrency limit. After this limit >> is reached no further tasks will be run until the current tasks are >> completed. You can adjust the limit in the concurrent task options Warning: Running "imagemin:dist" (imagemin) task Warning: Error: Command failed: /var/www/html/mt060915-00-sara/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor/optipng -strip all -quiet -clobber -o 3 -out /tmp/779c540d-814c-4996-a3c1-9ac2dd258ce6 /tmp/bbb66aa4-f646-41dd-8dd1-92f7440c5166 /var/www/html/mt060915-00-sara/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor/optipng: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /var/www/html/mt060915-00-sara/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor/optipng) in file app/images/ico-class.png Use --force to continue. Aborted due to warnings. Execution Time (2015-07-17 03:52:26 UTC) loading tasks 7ms ▇▇▇▇▇▇ 11% imagemin:dist 54ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 87% Total 62ms Use --force to continue. Aborted due to warnings. Execution Time (2015-07-17 03:52:24 UTC) wiredep:app 165ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 7% includeSource:dist 27ms ▇▇▇ 1% concurrent:dist 2s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 89% Total 2.2s 

这是package.json文件的内容:

 { "name": "webapp", "version": "0.0.0", "private": true, "dependencies": { "angular-momentjs": "~0.1.8" }, "devDependencies": { "grunt": "^0.4.1", "grunt-autoprefixer": "^0.7.3", "grunt-concurrent": "^0.5.0", "grunt-contrib-clean": "^0.5.0", "grunt-contrib-compass": "^1.0.1", "grunt-contrib-concat": "^0.4.0", "grunt-contrib-connect": "^0.7.1", "grunt-contrib-copy": "^0.5.0", "grunt-contrib-cssmin": "^0.9.0", "grunt-contrib-htmlmin": "^0.3.0", "grunt-contrib-imagemin": "^0.8.1", "grunt-contrib-jshint": "^0.10.0", "grunt-contrib-uglify": "^0.4.0", "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^0.2.1", "grunt-google-cdn": "^0.4.0", "grunt-include-source": "~0.4.1", "grunt-karma": "^0.8.3", "grunt-newer": "^0.7.0", "grunt-ngmin": "^0.0.3", "grunt-svgmin": "^0.4.0", "grunt-usemin": "^2.1.1", "grunt-wiredep": "1.8.0", "jshint-stylish": "^0.2.0", "karma": "^0.12.17", "karma-jasmine": "^0.1.5", "karma-phantomjs-launcher": "^0.1.4", "load-grunt-tasks": "^0.4.0", "time-grunt": "^0.3.1", "try-thread-sleep": "^1.0.0" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "grunt test" } } 

这是Gruntfile.js

 // Generated on 2014-07-15 using generator-angular 0.9.5 'use strict'; // # Globbing // for performance reasons we're only matching one level down: // 'test/spec/{,*/}*.js' // use this if you want to recursively match all subfolders: // 'test/spec/**/*.js' module.exports = function (grunt) { // Load grunt tasks automatically require('load-grunt-tasks')(grunt); // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); // Configurable paths for the application var appConfig = { app: require('./bower.json').appPath || 'app', dist: 'dist' }; grunt.loadNpmTasks('grunt-include-source'); // Define the configuration for all the tasks grunt.initConfig({ // Project settings yeoman: appConfig, // includes project files to index.html includeSource: { options: { basePath: 'app', baseUrl: '/' }, server: { files: { '.tmp/index.html': '<%= yeoman.app %>/index.html' } }, dist: { files: { '<%= yeoman.dist %>/index.html': '<%= yeoman.app %>/index.html' } } }, // Watches files for changes and runs tasks based on the changed files watch: { bower: { files: ['bower.json'], tasks: ['wiredep'] }, includeSource: { files: ['<%= yeoman.app %>/index.html'], tasks: ['includeSource:server'] }, js: { files: ['<%= yeoman.app %>/scripts/{,*/}*.js'], tasks: ['newer:jshint:all'], options: { livereload: '<%= connect.options.livereload %>' } }, jsTest: { files: ['test/spec/{,*/}*.js'], tasks: ['newer:jshint:test', 'karma'] }, compass: { files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'], tasks: ['compass:server', 'autoprefixer'] }, gruntfile: { files: ['Gruntfile.js'] }, livereload: { options: { livereload: '<%= connect.options.livereload %>' }, files: [ '<%= yeoman.app %>/{,*/}*.html', '<%= yeoman.app %>/views/{,*/}*.html', '.tmp/styles/{,*/}*.css', '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] } }, // The actual grunt server settings connect: { options: { port: 9000, // Change this to '0.0.0.0' to access the server from outside. hostname: '0.0.0.0', livereload: 35729 }, livereload: { options: { open: true, middleware: function (connect) { return [ connect.static('.tmp'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ]; } } }, test: { options: { port: 9001, middleware: function (connect) { return [ connect.static('.tmp'), connect.static('test'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ]; } } }, dist: { options: { open: true, base: '<%= yeoman.dist %>' } } }, // Make sure code styles are up to par and there are no obvious mistakes jshint: { options: { jshintrc: '.jshintrc', reporter: require('jshint-stylish') }, all: { src: [ 'Gruntfile.js', '<%= yeoman.app %>/scripts/{,*/}*.js' ] }, test: { options: { jshintrc: 'test/.jshintrc' }, src: ['test/spec/{,*/}*.js'] } }, // Empties folders to start fresh clean: { dist: { files: [{ dot: true, src: [ '.tmp', '<%= yeoman.dist %>/{,*/}*.*', '!<%= yeoman.dist %>/.git*', '!<%= yeoman.dist %>/.svn*', '!<%= yeoman.dist %>/{,*/}.svn*' ] }] }, server: '.tmp' }, // Add vendor prefixed styles autoprefixer: { options: { browsers: ['last 1 version'] }, dist: { files: [{ expand: true, cwd: '.tmp/styles/', src: '{,*/}*.css', dest: '.tmp/styles/' }] } }, // Automatically inject Bower components into the app wiredep: { options: { cwd: '<%= yeoman.app %>' }, app: { src: ['<%= yeoman.app %>/index.html'], ignorePath: /\.\.\// }, sass: { src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'], ignorePath: /(\.\.\/){1,2}bower_components\// } }, // Compiles Sass to CSS and generates necessary files if requested compass: { options: { sassDir: '<%= yeoman.app %>/styles', cssDir: '.tmp/styles', generatedImagesDir: '.tmp/images/generated', imagesDir: '<%= yeoman.app %>/images', javascriptsDir: '<%= yeoman.app %>/scripts', fontsDir: '<%= yeoman.app %>/styles/fonts', importPath: './bower_components', httpImagesPath: '/images', httpGeneratedImagesPath: '/images/generated', httpFontsPath: '/styles/fonts', relativeAssets: false, assetCacheBuster: false, raw: 'Sass::Script::Number.precision = 10\n' }, dist: { options: { generatedImagesDir: '<%= yeoman.dist %>/images/generated' } }, server: { options: { debugInfo: true } } }, // Renames files for browser caching purposes filerev: { dist: { src: [ '<%= yeoman.dist %>/scripts/{,*/}*.js', '<%= yeoman.dist %>/styles/{,*/}*.css' //'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' // '<%= yeoman.dist %>/styles/fonts/**/*.{eot,svg,ttf,woff}' ] } }, // Reads HTML for usemin blocks to enable smart builds that automatically // concat, minify and revision files. Creates configurations in memory so // additional tasks can oper // ate on them useminPrepare: { html: '<%= yeoman.dist %>/index.html', options: { dest: '<%= yeoman.dist %>', flow: { html: { steps: { js: ['concat', 'uglifyjs'], css: ['cssmin'] }, post: {} } } } }, // Performs rewrites based on filerev and the useminPrepare configuration usemin: { html: ['<%= yeoman.dist %>/{,*/}*.html'], css: ['<%= yeoman.dist %>/styles/{,*/}*.css'], options: { assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images'] } }, // The following *-min tasks will produce minified files in the dist folder // By default, your `index.html`'s <!-- Usemin block --> will take care of // minification. These next options are pre-configured if you do not wish imagemin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/images', src: '{,*/}*.{png,jpg,jpeg,gif}', dest: '<%= yeoman.dist %>/images' }] } }, svgmin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/images', src: '{,*/}*.svg', dest: '<%= yeoman.dist %>/images' }] } }, htmlmin: { dist: { options: { collapseWhitespace: true, conservativeCollapse: true, collapseBooleanAttributes: true, removeCommentsFromCDATA: true, removeOptionalTags: true }, files: [{ expand: true, cwd: '<%= yeoman.dist %>', src: ['*.html', 'views/{,**/}*.html'], dest: '<%= yeoman.dist %>' }] } }, // ngmin tries to make the code safe for minification automatically by // using the Angular long form for dependency injection. It doesn't work on // things like resolve or inject so those have to be done manually. ngmin: { dist: { files: [{ expand: true, cwd: '.tmp/concat/scripts', src: '*.js', dest: '.tmp/concat/scripts' }] } }, // Replace Google CDN references cdnify: { dist: { html: ['<%= yeoman.dist %>/*.html'] } }, // Copies remaining files to places other tasks can use copy: { dist: { files: [{ expand: true, dot: true, cwd: '<%= yeoman.app %>', dest: '<%= yeoman.dist %>', src: [ '*.{ico,png,txt}', '.htaccess', '*.html', 'views/{,**/}*.html', 'images/{,*/}*.{webp}', 'styles/fonts/**/*', 'fonts/*', 'sounds/*' ] }, { expand: true, cwd: '.tmp/images', dest: '<%= yeoman.dist %>/images', src: ['generated/*'] }, { expand: true, cwd: '.', src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*', dest: '<%= yeoman.dist %>' }] }, styles: { expand: true, cwd: '<%= yeoman.app %>/styles', dest: '.tmp/styles/', src: '{,*/}*.css' } }, // Run some tasks in parallel to speed up the build process concurrent: { server: [ 'compass:server' ], test: [ 'compass' ], dist: [ 'compass:dist', 'imagemin', 'svgmin' ] }, // Test settings karma: { unit: { configFile: 'test/karma.conf.js', singleRun: true } } }); grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { if (target === 'dist') { return grunt.task.run(['build', 'connect:dist:keepalive']); } grunt.task.run([ 'clean:server', 'wiredep', 'includeSource', 'concurrent:server', 'autoprefixer', 'connect:livereload', 'watch' ]); }); grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) { grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); grunt.task.run(['serve:' + target]); }); grunt.registerTask('test', [ 'clean:server', 'concurrent:test', 'autoprefixer', 'connect:test', 'karma' ]); grunt.registerTask('build', [ 'clean:dist', 'wiredep', 'includeSource:dist', 'useminPrepare', 'concurrent:dist', 'autoprefixer', 'concat', 'ngmin', 'copy:dist', 'cdnify', 'cssmin', 'uglify', 'filerev', 'usemin', 'htmlmin' ]); grunt.registerTask('default', [ 'newer:jshint', 'test', 'build' ]); }; 

我已经看到这个问题,并试图在那里的一切,但不为我工作。 哪里不对? 这让我疯狂,我不知道为什么或者哪里失败,有什么build议?

尝试这个:

 npm install grunt-contrib-imagemin --save-dev 

或将imagemin的版本更改为“grunt-contrib-imagemin”:“^ 0.9.4”

在你的Gruntfile.js中改变:

 src: '{,*/}*.{png,jpg,jpeg,gif}', 

 src: '[*/*.{png,jpg,jpeg,gif,svg}]', 

更新了package.json中的grunt-contrib-imagemin版本

“grunt-contrib-imagemin”:“〜1.0.0”

那么,npm clean cache npm install grunt-contrib-imagemin