Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack.optimize.OccurenceOrderPlugin is not a constructor Error #155

Closed
outsideris opened this issue Feb 7, 2017 · 4 comments
Closed

Comments

@outsideris
Copy link

When I run npm test, I encountered following error.

webpack-validator/test/passing-configs/angular2-webpack-starter.development.js:73
  plugins: [new webpack.optimize.OccurenceOrderPlugin(true), new webpack.optimize.CommonsChunkPlugin({ name: 'polyfills', filename: 'polyfills.bundle.js', minChunks: Infinity }),
            ^

TypeError: webpack.optimize.OccurenceOrderPlugin is not a constructor
    at Object.<anonymous> (angular2-webpack-starter.development.js:73:5)
    at Module._compile (module.js:570:32)
    at loader (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/babel-register/lib/node.js:126:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/babel-register/lib/node.js:136:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at filePathToConfigObj (index.js:6:16)
    at Array.map (native)
    at Object.<anonymous> (index.js:20:3)
    at Module._compile (module.js:570:32)
    at loader (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/babel-register/lib/node.js:126:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/babel-register/lib/node.js:136:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (index.test.js:2:1)
    at Module._compile (module.js:570:32)
    at loader (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/babel-register/lib/node.js:126:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/babel-register/lib/node.js:136:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at /Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/mocha/lib/mocha.js:219:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/mocha/lib/mocha.js:216:14)
    at Mocha.run (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/mocha/lib/mocha.js:468:10)
    at Object.<anonymous> (/Users/outsider/Dropbox/projects/github/webpack-validator/node_modules/mocha/bin/_mocha:403:18)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
npm ERR! Test failed.  See above for more details.

As I dig the reason, I guess it caused because OccurenceOrderPlugin has been renamed to OccurrenceOrderPlugin. See webpack/webpack#1964 .
All tests are passed when I change OccurenceOrderPlugin to OccurrenceOrderPlugin in the test.

However, I'm not sure it is a common problem or just for me.

@outsideris
Copy link
Author

In my pull request, the same error is occurred. If you confirmed, I could fix it.

@kentcdodds
Copy link
Collaborator

If you're using Webpack 2, then please uninstall webpack-validator and close this issue. See the note in the README about webpack 2 not being supported (it has its own validation built-in 🎉)

@simeyla
Copy link

simeyla commented Jun 6, 2017

As said above OccurenceOrderPlugin is renamed to OccurrenceOrderPlugin (spelling mistake)

However it was not mentioned that it is now enabled by default - so you can just remove the line

    new webpack.optimize.OccurenceOrderPlugin(),

@xubeng
Copy link

xubeng commented Jul 4, 2018

@simeyla It does not work. Then output:
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants