英文:
TS2305: Module '"@prisma/client"' has no exported member 'User'
问题
I am try to set up a Gitlab CI for a nestjs project that uses prisma. When I run the pipeline, I get this error:
enter image description here
My .gitlab-ci.yml:
image: node:latest
stages:
- build
build:
stage: build
before_script:
- corepack enable
- corepack prepare pnpm@latest-8 --activate
- pnpm config set store-dir .pnpm-store
script:
- pnpm install
- npx prisma generate
- pnpm run build
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
artifacts:
paths:
- dist
user.models.ts
:
import { User } from "@prisma/client"; # Line that is causing the build to fail in the CI
import { IsEmail, IsInt, IsNotEmpty, IsString } from "class-validator";
class UserModel implements User {
@IsNotEmpty()
@IsInt()
id: number;
@IsNotEmpty()
@IsString()
@IsEmail()
email: string;
@IsNotEmpty()
@IsString()
password: string;
}
Running pnpm run build
locally works fine.
With the following scripts I have manually looked at the output generated by prisma, and I can see that User
is being exported as a type from index.d.ts
:
- cd ./node_modules/.prisma/client
- cat index.d.ts
- cd ../../..
英文:
I am try to set up a Gitlab CI for a nestjs project that uses prisma. When I run the pipeline, I get this error:
enter image description here
My .gitlab-ci.yml:
image: node:latest
stages:
- build
build:
stage: build
before_script:
- corepack enable
- corepack prepare pnpm@latest-8 --activate
- pnpm config set store-dir .pnpm-store
script:
- pnpm install
- npx prisma generate
- pnpm run build
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
artifacts:
paths:
- dist
user.models.ts
:
import { User } from "@prisma/client"; # Line that is causing the build to fail in the CI
import { IsEmail, IsInt, IsNotEmpty, IsString } from "class-validator";
class UserModel implements User {
@IsNotEmpty()
@IsInt()
id: number;
@IsNotEmpty()
@IsString()
@IsEmail()
email: string;
@IsNotEmpty()
@IsString()
password: string;
}
Running pnpm run build
locally works fine.
With the following scripts I have manually looked at the output generated by prisma, and I can see that User
is being exported as a type from index.d.ts
.
- cd ./node_modules/.prisma/client
- cat index.d.ts
- cd ../../..
答案1
得分: 0
请确保您在 prisma.schema 文件中为 types to stored 设置了正确的输出值,理想情况下,它将是您的 node_modules 目录下的路径:
generator client {
...
output = "../../node_modules/.prisma/client"
...
}
英文:
For anybody else with this issue, make sure you have set output value a it is below in your prisma.schema file for types to stored, this ideally will be your node_modules directory
generator client {
...
output = "../../node_modules/.prisma/client"
...
}
答案2
得分: -4
I needed to use import type { User }
instead of import { User }
.
英文:
I needed to use import type { User }
instead of import { User }
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论