webpack: webpack broken by ajv@6.9.0, "custom keyword definition is invalid: data.errors should be boolean"
Bug report
What is the current behavior? A fresh install of webpack will fail to run with the error “custom keyword definition is invalid: data.errors should be boolean” due to the latest version of ajv. See issue here https://github.com/epoberezkin/ajv/issues/941 referencing many other broken projects.
If the current behavior is a bug, please provide the steps to reproduce. Install webpack and attempt to use it.
What is the expected behavior? I expect webpack not to fail due to unreliable, auto-updating dependencies.
Other relevant information: webpack version: 4.28.4 Node.js version: 10.15.1 Operating System: Windows 10 Additional tools:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 163
- Comments: 75 (5 by maintainers)
Commits related to this issue
- fix: Webpack broken by AJV update Lock the version of AJV for now, until issue is resolved https://github.com/webpack/webpack/issues/8768 https://github.com/epoberezkin/ajv/issues/941 — committed to thebuilder/react-intersection-observer by thebuilder 5 years ago
- bug fixed https://github.com/webpack/webpack/issues/8768\?fbclid\=IwAR3UELDua5QEDpUxOzZGAcj7aL8jfQPXxXURlgKUFSi_kf4OkDpqyV_EiHY — committed to summerliu/weather-app by summerliu 5 years ago
- Fix webpack dependency issue As per https://github.com/webpack/webpack/issues/8768 Note that you may need to nuke your node_modules folder and reinstall — committed to TabbycatDebate/tabbycat by philipbelesky 5 years ago
- Update package.json — committed to misskey-dev/misskey by acid-chicken 5 years ago
- fix: Webpack broken by AJV update Lock the version of AJV for now, until issue is resolved https://github.com/webpack/webpack/issues/8768 https://github.com/epoberezkin/ajv/issues/941 — committed to johnrackles/react-intersection-observer by thebuilder 5 years ago
If you use yarn
add below to package.json
then run
yarn install
if you use npm
Or add this to your
package.json
:Then
yarn install
.For npm users:
Quick fix, in node_modules\ajv\lib\keyword.js I commented out if (!validateDefinition(definition)) throw new Error('custom keyword definition is invalid: ’ + this.errorsText(validateDefinition.errors)); and it works, still waiting for fix
Worked for me, npm uninstall ajv npm install ajv@6.8.1
same here
Same
To fix this error, just change: Line 14:
errors: 'full',
to: Line 14:errors: true
in file node_modules\ajv-errors\index.jsWould this failure have been prevented if Webpack pinned all versions in
package.json
, and only updated them when all tests pass?I see this comment has a few thumbs downs already, but no discussion about why it’s a bad idea. I use this strategy in several open-source libraries with lots of projects depending on them. If it’s a bad idea, I’d like to know why. Please educate me.
Dependency updates can be maintained automatically by something like the renovate bot, or pseudo-manually using updtr.
Note that resolutions is a yarn feature and not an npm feature. From the linked ajv issue:
Hey everyone thanks for all the quick feedback. We will reach out to AJV and see if we can tighten up the communication channels for their API and will consider pinning this dep for the future. I will lock the thread once I get off mobile (bad winter storm here right now and losing power intermittently 😂🥶) since there are quite a few workarounds posted!
This worked for me! Thanks!
I did, didn’t seem to fix it for me either.
Seems so simple I would love it to work, but getting same error, anything else I should look at?
Worked like a charm!
Ran into this when updating the dev deps for Aurelia, it breaks just about everything. I have a PR open here: https://github.com/epoberezkin/ajv/pull/943 (FYI: I am NOT the maintainer of the project, just trying to help)
Another option is to lockdown to 4.28.x the webpack itself
updating package-lock.json definitions worked on my end, there were many referencing 6.9.0 and I clobbered them all back to 6.8.1 as below.
https://stackoverflow.com/a/48524488
That’s 64 and 65
OK “resolutions” trick posted by @tyteen4a03 works
For those who “resolutions” method doesn’t work, for some reason, just explicitly define “ajv”: “6.8.1” in your package.json dependencies.
Thank you for this 😄
@jaydenseric I disagree strongly for actively maintained projects with lots of dependents. I added some tooling to help automate maintenance to keep dependencies up-to-date without risking breaking downstream projects.
I think threads like this one are ample evidence of the other side of the cost argument.
Failing to pin dependencies in a popular library is also a fairly serious security risk.
This doesn’t help fresh installs.
Have you reinstalled your packages with npm install? ;p
I’ve created a minimal reproduction repository: https://github.com/acro5piano/webpack-issues-8768
It is fixed so let’s wait a little more:) https://github.com/epoberezkin/ajv/pull/943
Also working for me. On another note, look at all us cool guys working on a Saturday night. lol
@youngzaphod Yes, I saw the same error, and then installed yarn. I’m glad you also solved the problem in one way or another!
I had the same problem. For me it only worked after installing yarn: https://yarnpkg.com/lang/en/docs/install/#debian-stable
Then run
yarn
.@youngzaphod Please see updated comment for npm (or switch to Yarn)
@jackturnbull Thanks - I was just about to clarify.
@JesusViveros12 node_modules/ajv/lib/keyword.js 64 and 65