Sage 9 - npm run build failing --> 'imagemin-webpack-plugin'

I’m getting the following error:

npm run build

sage@9.0.0-alpha.3 build /Users/me/code/servers/
webpack --progress --config assets/build/webpack.config.js

new ImageminPlugin({

ReferenceError: ImageminPlugin is not defined
at Object. (/Users/me/code/servers/
at Module._compile (module.js:409:26)
at Object.Module._extensions…js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at module.exports (/Users/me/code/servers/
at Object. (/Users/me/code/servers/
at Module._compile (module.js:409:26)

npm ERR! Darwin 15.6.0
npm ERR! argv “/Users/me/.nvm/versions/node/v4.6.0/bin/node” “/Users/me/.nvm/versions/node/v4.6.0/bin/npm” “run” “build”
npm ERR! node v4.6.0
npm ERR! npm v3.10.8
npm ERR! sage@9.0.0-alpha.3 build: webpack --progress --config assets/build/webpack.config.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sage@9.0.0-alpha.3 build script ‘webpack --progress --config assets/build/webpack.config.js’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sage package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --progress --config assets/build/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sage
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls sage
npm ERR! There is likely additional logging output above.

I solved by commenting out the following lines in the webpack.config.js file:

// const ImageminPlugin = require('imagemin-webpack-plugin').default; 

  //  new ImageminPlugin({
  //    optipng: {
  //      optimizationLevel: 7,
  //    },
  //    gifsicle: {
  //      optimizationLevel: 3,
  //    },
  //    pngquant: {
  //      quality: '65-90',
  //      speed: 4,
  //    },
  //    svgo: {
  //      removeUnknownsAndDefaults: false,
  //      cleanupIDs: false,
  //    },
  //    jpegtran: null,
  //    plugins: [imageminMozjpeg({
  //      quality: 75,
  //    })],
  //    disable: (config.enabled.watcher),
  //  }),

Upgrading imagemin-webpack-plugin to version 1.2.0 DOES NOT fix this error.

I have the same error here.

It’s related to this bug on async-throttle package. Hope they’re gonna merge the PR soon

1 Like

Although, not the “proper” way to fix, BUT for a quick and simple fix just add "use strict" to line 1 of node_modules/async-throttle/index.js
Make sure to include double quotes --> "use strict"

To see the change, here’s the link to the git commit -->