I’m building an extension for Prisma, and I’ve put two workspaces into a monorepo, one for the package itself, and one for development testing:
/package.json
/pnpm-workspace.yaml
/package/package.json
/dev-test/package.json
In both the package itself and the test workspace, I have prisma
as a dev dependency. In the package itself, I have @prisma/client
as a peer dependency, and as a full dependency in the test space.
The issue I’m facing is, it often occurs that it will install a different patch version of the client than of the main prisma module. For example, right now it’s installing [email protected]
and @prisma/[email protected]
. This can, and does, result in problems, so the question is, how do I get pnpm
to make sure they stay in sync?
Here are the relevant sections of the package.json
files:
# file=/package.json
# i.e., nothing to do with prisma or @prisma/client in the root package.json
{
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.6"
},
}
# file=/package/package.json
{
"peerDependencies": {
"@prisma/client": "^5.14.0",
},
"devDependencies": {
"prisma": "^5.14.0",
}
}
# file=/dev-test/package.json
{
"dependencies": {
"@prisma/client": "^5.14.0",
"prisma-extension-pgvector": "workspace:^"
},
"devDependencies": {
"prisma": "^5.14.0"
}
}
This Q&A are slightly different, because they’re trying to sync the same package version in different workspaces, rather than sync versions between different packages. Nevertheless, it pointed me at overrides as a potential solution, but I can’t get that to work.
I tried using
"pnpm": {
"overrides": {
"@prisma/client": "$prisma"
}
}
to force @prisma/client
to use the same version as prisma
, but if I put it in dev-test/package.json
, it complains
WARN The field “pnpm” was found in dev-test/package.json. This will not take effect. You should configure “pnpm” at the root of the workspace instead.
Whereas, if I do as suggested and put it in the root of the workspace, it complains
ERR_PNPM_CANNOT_RESOLVE_OVERRIDE_VERSION Cannot resolve version $prisma in overrides. The direct dependencies don’t have dependency “prisma”.
Ideas? What else can I try?