从 @prisma/client导入枚举给出了“模块” @prisma/client&quot&quot&quot&quot&quot&quot&quot&quot&quot&quot'没有导出的成员模态'

发布于 2025-02-13 07:56:55 字数 856 浏览 0 评论 0原文

我想在ORM模型中使用我在schema.prisma文件中定义的枚举(我正在使用TypeGraphQL)。

我的Prisma模式定义为

enum Modality {
    CT
    MAMMO
    MRI
    STEREO
}

在运行npx Prisma生成后,以下打字稿代码生成错误。

import { Modality } from "@prisma/client";

> src/schema/ImagingCenter.ts:4:10 - error TS2305: Module '"@prisma/client"' has no exported member 'Modality'.

我能够导入Prismaclient并在我的应用程序中使用它,但是我无法导入任何特定类型或枚举。

我在Prisma客户端〜3.11.0,并且在我的tsconfig.json中有以下内容:

        "target": "es2018",
        "allowJs": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "allowSyntheticDefaultImports": true,

根据这篇文章,我的设置似乎可以正常工作吗? 如何在Prisma Client中获得枚举?

I want to use the Enum I defined in my schema.prisma file in my ORM model (I'm using TypeGraphQL).

My prisma schema is defined as

enum Modality {
    CT
    MAMMO
    MRI
    STEREO
}

After running npx prisma generate, the following TypeScript code generates an error.

import { Modality } from "@prisma/client";

> src/schema/ImagingCenter.ts:4:10 - error TS2305: Module '"@prisma/client"' has no exported member 'Modality'.

I'm able to import PrismaClient and use it just fine in my application, but I'm unable to import any particular types or enums.

I'm on Prisma client ~3.11.0 and have the following in my tsconfig.json:

        "target": "es2018",
        "allowJs": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "allowSyntheticDefaultImports": true,

Based on this post, it seems like my setup should work fine? How to get enums in prisma client?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心不设防 2025-02-20 07:56:55

确保您运行了

prisma generate

yarn build

我也遇到了这个问题,这些命令可以解决

Make sure you have run

prisma generate

and

yarn build

I've faced this problem too and these commands can fix

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文