webpacktravis-ciwebpack-3

webpack.optimize.ModuleConcatenationPlugin is not a constructor


Getting the following error on Travis CI since upgrading to Webpack 3.

It seems to work fine on my local environment, but when I commit to master and kick of Travis it keeps failing now with the following error.

21 06 2017 20:16:31.514:ERROR [config]: Invalid config file!
  TypeError: webpack.optimize.ModuleConcatenationPlugin is not a constructor
    at Object.<anonymous> (/home/travis/build/.../webpack.prod.config.babel.js:91:3)
    at Module._compile (module.js:569:30)
    at loader (/home/travis/build/.../node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/travis/build/.../node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

And the Line it's complaining about

// Webpack 3 Scope Hoisting
new webpack.optimize.ModuleConcatenationPlugin(),

And also have set Webpack to version 3 in my package.json of course.

"webpack": "^3.0.0",

And my Travis yml is pretty simple

language: node_js
sudo: false
node_js:
- '8'

Solution

  • Delete node_modules and package-lock.json then run npm install again to generate a new package-lock.json. Once you commit the new package-lock.json, Travis should work correctly.

    I was having the exact same issue locally, I did what I described and I stopped having that issue.