简体   繁体   中英

grunt-contrig-imagemin Warning: Cannot call method 'replace' of undefined

I'm getting a weird warning when trying to use imagemin and nothing happens.

grunt imagemin:primary

Warning: Cannot call method 'replace' of undefined Used --force, continuing.
Done, but with warnings.

My task that gives me the error is as follows

  grunt.config 'imagemin'

    primary:
      options:
        optimizationLevel: 7
      expand: true
      cwd: "assets"
      src: "{img,img_two}/**/*.{jpg,jpeg,gif,png}"
      dest: "public/compiled/img"


  grunt.loadNpmTasks 'grunt-contrib-imagemin'

These don't work

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

src: "{img,img_two}/**/*.{jpg,jpeg,gif,png}"

These work

src: "img/**/*.jpg"

src: "{img,img_two}/**/*.jpg"

So it seems it doesn't like multiple extensions syntax but why, it's even how it's done in the example?

UPDATE: it seems it's just PNG that doesn't work whether I do the extension on it's own or within a group matching. I'm on Windows 8, NPM 1.4.3

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

Had the same problem I fixed it by deleting the grunt-contrib-imagemin directory located inside node_modules

Then I ran "npm install grunt-contrib-imagemin" to grab the latest version.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM