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 ../../..
For anybody else with this issue, make sure you have set output value as it is below in your prisma.schema file for types to be stored, this ideally will be your node_modules directory
generator client {
...
output = "../../node_modules/.prisma/client"
...
}