Closed dhkatz closed 2 years ago
joiful
used to list joi
as a peer dependency. We changed it to a regular dependency in this commit, when we upgraded from joi@10
to @hapi/joi@15
. I don't recall why we changed it from a peer dependency. I think it was to avoid issues where the installed version of Joi had unexpected breaking changes.
If you use yarn
v1.x (which I strongly recommend over npm
), you can work around this using selective dependency resolution in your package.json
.
"resolutions": {
"joi": "17.5.0",
}
(If there's a mix of dependencies on joi
and @hapi/joi
, you're in trouble... 😬)
Switching to yarn and adding the resolution seems to have worked. I should say also that npm does have its own version called overrides. Odd that they (or node) haven't decided on a common name
I recently ran into an issue with another library that depends on Joi.
Because of adependency mismatch the following error gets thrown by Joi:
'Cannot mix different versions of joi schemas'
.The other library has Joi listed as a peer dependency which I believe is the correct way of handling Joi.
Because this library has a dependency instead, Joiful gets its own version of Joi installed instead of sharing an existing compatible version.
This is an example of the dependency issue caused by not listing Joi as a peer dependency.