prisma-nestjs-graphql 始终使用 prisma@5.0.0 生成类型。

huangapple go评论67阅读模式
英文:

prisma-nestjs-graphql always using prisma@5.0.0 to generate types

问题

我在我的monorepo项目中使用prisma-nestjs-graphql生成器和pnpm遇到了问题。我的后端项目位于以下结构中:root/apps/server

这是我的prisma依赖项和生成器的概述:

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

问题是,当我运行命令:pnpx prisma generate 时,prisma-nestjs-graphql生成器使用了prisma 版本5.0.0,尽管我已经指定了版本4.15.0,并且我得到了以下输出:

warn Versions of prisma@5.0.0 and @prisma/client@4.15.0 don't match.
This might lead to unexpected behavior.
Please make sure they have the same version.

我认为这是pnpm的问题,它可能在某种情况下使用了缓存或其他东西,这里是生成器在pnpm中保存文件夹和临时文件的详细输出:

../../../../../../../AppData/Local/pnpm/store/v3/tmp/dlx-13616/node_modules/.pnpm
/prisma@5.0.0/node_modules/prisma: 
Running preinst../../../../../../../AppData/Local/pnpm/store/v3/tmp/dlx-13616/node_modules/.pnpm/prisma@5.0.0/node_modules/prisma: 
Running preinstall script, done in 118ms

正如你所看到的,它使用了prisma@5.0.0版本。

我尝试删除了pnpm store、node_modules、pnpm-lock.yaml文件、/server项目的node_modules,以及我的计算机上的pnpm_cache文件夹,并重新安装了所有内容,但没有改变任何东西。

有人知道问题是什么吗?谢谢。

英文:

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 prisma@5.0.0 and @prisma/client@4.15.0 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
/prisma@5.0.0/node_modules/prisma: 
Running preinst../../../../../../../AppData/Local/pnpm/store/v3/tmp/dlx-13616/node_modules/.pnpm/prisma@5.0.0/node_modules/prisma: 
Running preinstall script, done in 118ms

As you can see, he uses the prisma@5.0.0 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

得分: 1

你可以告诉pnpm始终使用特定版本的软件包。您可以在项目的根目录下添加一个pnpmfile.js文件,内容如下:

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

这个文件告诉pnpm始终使用Prisma 4.15.0版本用于prisma-nestjs-graphql,覆盖了它在package.json中指定的版本。

英文:

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.

huangapple
  • 本文由 发表于 2023年7月14日 00:45:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76681656.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定