webpack-dev-server: throw new Error('invalid "instanceof" keyword value ' + c);

Getting this error while running webpack-dev-server --config ./webpack.client.js --hot

  • Operating System: Mac OS High Sierra
  • Node Version: 9.9.0
  • NPM Version: 5.7.1
  • webpack Version: 4.1.1
  • webpack-dev-server Version:3.1.1 Full stacktrace
node_modules/webpack/node_modules/ajv-keywords/keywords/instanceof.js:52
    throw new Error('invalid "instanceof" keyword value ' + c);
    ^

Error: invalid "instanceof" keyword value Promise
    at getConstructor (node_modules/webpack/node_modules/ajv-keywords/keywords/instanceof.js:52:11)
    at Ajv.compile (node_modules/webpack/node_modules/ajv-keywords/keywords/instanceof.js:21:27)
    at Object.useCustomRule (node_modules/webpack/node_modules/ajv/lib/compile/index.js:275:26)
    at Object.generate_custom [as code] (node_modules/webpack/node_modules/ajv/lib/dotjs/custom.js:32:24)
    at Object.generate_validate [as validate] (node_modules/webpack/node_modules/ajv/lib/dotjs/validate.js:347:35)
    at Object.generate_anyOf [as code] (node_modules/webpack/node_modules/ajv/lib/dotjs/anyOf.js:34:27)
    at generate_validate (node_modules/webpack/node_modules/ajv/lib/dotjs/validate.js:347:35)
    at localCompile (node_modules/webpack/node_modules/ajv/lib/compile/index.js:87:22)
    at Ajv.compile (node_modules/webpack/node_modules/ajv/lib/compile/index.js:56:13)
    at Ajv._compile (node_modules/webpack/node_modules/ajv/lib/ajv.js:358:27)
    at Ajv.compile (node_modules/webpack/node_modules/ajv/lib/ajv.js:118:37)
    at validateObject (node_modules/webpack/lib/validateSchema.js:36:23)
    at validateSchema (node_modules/webpack/lib/validateSchema.js:31:10)
    at processConfiguredOptions (node_modules/webpack-cli/bin/convert-argv.js:156:48)
    at module.exports (node_modules/webpack-cli/bin/convert-argv.js:150:10)
    at Object.<anonymous> (node_modules/webpack-dev-server/bin/webpack-dev-server.js:234:54)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 37
  • Comments: 18 (1 by maintainers)

Most upvoted comments

why do bad things happen to good people?

we manually hacked our package.json to use webpack 4.2.0 and this error goes away!

woo!

So this happened because webpack pushed breaking changes in a minor version and most people probably have their package.json file with a carrot or tilde in front of the webpack dependencies. Removing that carrot or tilde to freeze to the version specified and running npm install fixed the problem for me.

I think it’s extremely irresponsible for webpack to have made these breaking changes in a minor version. The webpack CLI separation should have only occurred in a major release. You have literally millions of people depending on this package, please put some more thought into release numbers.

I solved by lowerring my webpack-dev-server version,The problem is there

@ndabAP 2.9.1

remember to lower your webpack-dev-server globaly not localy use : npm install webpack-dev-server@2.9.1 -g --save-dev and after that you are set

npm install webpack-dev-server@2.x, works for me.

npm i webpack@latest -g helps me

Had this issue today, and went away, after upgrading webpack to 4.5.0 and also installing webpack-cli locally…

you can use npm run build instead of

following worked for me npm install webpack-dev-server@2.11.0 --save-dev

I had a similar issue but it was due to not having webpack-cli installed locally.