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

Created on 24 Mar 2018  ยท  18Comments  ยท  Source: webpack/webpack-dev-server

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)

Most helpful comment

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!

All 18 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!

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

@DCbryant which version do you use now?

@ndabAP 2.9.1

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

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

npm i webpack@latest -g helps me

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 have this error in a lerna project when I try to install in two different package it then fail to find the module webpack-cli:

$ ./node_modules/.bin/webpack-dev-server --progress --color --hot --watch --mode development
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
module.js:559
    throw err;
    ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)
error An unexpected error occurred: "Command failed.
````

so I moved it to the top package.json, and then I have this error:

```bash
yarn run v1.5.1
$ ./node_modules/.bin/webpack-dev-server --progress --color --hot --watch --mode development
/home/dka/workspace/github.com/yeutech/react-admin/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 (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/webpack/node_modules/ajv-keywords/keywords/instanceof.js:52:11)
    at Ajv.compile (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/webpack/node_modules/ajv-keywords/keywords/instanceof.js:21:27)
    at Object.useCustomRule (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/compile/index.js:275:26)
    at Object.generate_custom [as code] (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/dotjs/custom.js:32:24)
    at Object.generate_validate [as validate] (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/dotjs/validate.js:347:35)
    at Object.generate_anyOf [as code] (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/dotjs/anyOf.js:34:27)
    at generate_validate (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/dotjs/validate.js:347:35)
    at localCompile (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/compile/index.js:87:22)
    at Ajv.compile (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/compile/index.js:56:13)
    at Ajv._compile (/home/dka/workspace/github.com/yeutech/react-admin/node_modules/ajv/lib/ajv.js:358:27)
error An unexpected error occurred: "Command failed.
Exit code: 1

I have tried to downgrade webpack from 4.5.0 to 4.2.0 as @silky recommend but that doesn't help.

Any idea on how to solve this?

maybe you can change your package.json
update the webpack to 4.X
delete your node_modules
npm install again
and then it's work

@kopax, I was able to solve this by updating lerna to 2.10.0 from 2.0.0-rc5, and updating webpack in all my package.json files. I believe the problem stemmed from the fact that I was updating webpack one project at a time, and I was hoisting the modules with lerna, but the updates resolved it.

It looks like this issue is related to webpack and/or webpack-cli, not webpack-dev-server, so I'm closing this. If you believe this is an issue in WDS please provide a test repository, because I cannot reproduce this.

remember to lower your webpack-dev-server globaly not localy use :
npm install [email protected] -g --save-dev and after that you are set

npm install [email protected], works for me.

I read this topic for a second time within 2 weeks so I decided to write down my own suggestions in case I will come back anytime in the future;) The below is a complete list of dependencies I had to upgrade to upgrade from vulnerable [email protected] to @16.0.1:

โฏ yarn add [email protected] [email protected] [email protected] [email protected] extract-text-webpack-plugin@next
โฏ yarn add -D webpack-cli

remove node_modules
npm install
add --mode development to your CLI command (webpack-dev-server --mode development)
try again to start the project with yarn run dev-server (or whatever is your script to run the project locally)

you can use npm run build instead of

following worked for me
npm install [email protected] --save-dev

following worked for me
npm install [email protected] --save-dev

Thank you, this is actually worked..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

da2018 picture da2018  ยท  3Comments

StephanBijzitter picture StephanBijzitter  ยท  3Comments

daryn-k picture daryn-k  ยท  3Comments

movie4 picture movie4  ยท  3Comments

mischkl picture mischkl  ยท  3Comments