prisma-nestjs-graphql always using [email protected] to generate types

236 Views Asked by At

I have a problem with the prisma-nestjs-graphql generator and pnpm in my monorepo project. My backend is in the following structure: root/apps/server

Here's an overview of my prisma dependencies and the generator:

"dependencies": {
        "@prisma/client": "^4.15.0",
    },
    "devDependencies": {
        "prisma": "^4.15.0",
        "prisma-nestjs-graphql": "^18.0.2",
        "typescript": "^4.7.4"
    },

The problem is that when I use the command : pnpx prisma generate, the prisma-nestjs-graphql generator uses prisma version 5.0.0 even if I have specified the version 4.15.0 and I get the following output:

warn Versions of [email protected] and @prisma/[email protected] don't match.
This might lead to unexpected behavior.
Please make sure they have the same version.

I think it's a problem with pnpm which must use cache or something, here's the detailed output of the location where the generator saves a folder and temporary files in pnpm :

../../../../../../../AppData/Local/pnpm/store/v3/tmp/dlx-13616/node_modules/.pnpm
/[email protected]/node_modules/prisma: 
Running preinst../../../../../../../AppData/Local/pnpm/store/v3/tmp/dlx-13616/node_modules/.pnpm/[email protected]/node_modules/prisma: 
Running preinstall script, done in 118ms

As you can see, he uses the [email protected] version

I tried deleting the pnpm store, the node_modules, the pnpm-lock.yaml file, the node_modules of the /server project, and also the pnpm_cache folder in my pc, and reinstalling everything, but it didn't change anything.

Does anyone know what the problem is? Thanks

1

There are 1 best solutions below

2
Nurul Sundarani On

You can tell pnpm to always use a specific version of a package. You can add a pnpmfile.js at the root of your project with the following content:

module.exports = {
  hooks: {
    readPackage(packageJson) {
      if (packageJson.name === 'prisma-nestjs-graphql') {
        packageJson.dependencies.prisma = '^4.15.0';
      }
      return packageJson;
    },
  },
};

This file tells pnpm to always use Prisma 4.15.0 for prisma-nestjs-graphql, overriding the version specified in its package.json.