Hosting Typescript Express Server with Prisma on Vercel

I have hosted Express Server (Javascript) with Prisma on Vercel and it is working perfectly. Now I have a app on Typescript. As Vercel only works with Js files I have used build file. So, My question is how to include the prism generate file inside the /dist folder as when building with

rimraf dist && tsc

rimraf dist && tsc
I am not getting the /generated file on the dist file. My files are: package.json
{
"name": "prisma-server",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "nodemon ./src/server.ts",
"dev": "nodemon ./src/server.ts",
"seed": "ts-node src/seed.ts",
"postinstall": "prisma generate",
"build": "rimraf dist && tsc && copyfiles -u 1 'src/generated/prismaClient/**/*' dist/generated/prismaClient",
"ts.check": "tsc --project tsconfig.json",
"add-build": "git add dist",
"test": "echo \"Error: no test specified\" && exit 1"
}
]
}
{
"name": "prisma-server",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "nodemon ./src/server.ts",
"dev": "nodemon ./src/server.ts",
"seed": "ts-node src/seed.ts",
"postinstall": "prisma generate",
"build": "rimraf dist && tsc && copyfiles -u 1 'src/generated/prismaClient/**/*' dist/generated/prismaClient",
"ts.check": "tsc --project tsconfig.json",
"add-build": "git add dist",
"test": "echo \"Error: no test specified\" && exit 1"
}
]
}
1 Reply
Bibhushan Thapa
Bibhushan ThapaOP7mo ago
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"noImplicitReturns": false,
"noImplicitAny": true,
"resolveJsonModule": true,
"types" : ["node", "express"]
},
"include": ["src/**/*.ts", "src/generated/prismaClient/**/*.ts"],
"exclude": ["node_modules", "**/*.test.ts", "cypress", "docs", "scripts", "test"]
}
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"noImplicitReturns": false,
"noImplicitAny": true,
"resolveJsonModule": true,
"types" : ["node", "express"]
},
"include": ["src/**/*.ts", "src/generated/prismaClient/**/*.ts"],
"exclude": ["node_modules", "**/*.test.ts", "cypress", "docs", "scripts", "test"]
}
vercel.json
{
"version": 2,
"builds": [
{
"src": "dist/server.js",
"use": "@vercel/node",
"config": {
"includeFiles": [
"dist/**"
]
}
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/server.js",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"OPTIONS"
],
"headers": {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
"Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"
}
}
]
}
{
"version": 2,
"builds": [
{
"src": "dist/server.js",
"use": "@vercel/node",
"config": {
"includeFiles": [
"dist/**"
]
}
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/server.js",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"OPTIONS"
],
"headers": {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
"Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"
}
}
]
}
For work around I copied the generate file inside the dist build folder Now It is detecting the prisma but I am getting this error:
Unhandled Rejection: PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x".
This happened because Prisma Client was generated for "windows", but the actual deployment required "rhel-openssl-3.0.x".
Add "rhel-openssl-3.0.x" to `binaryTargets` in the "schema.prisma" file and run `prisma generate` after saving it:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}

Unhandled Rejection: PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x".
This happened because Prisma Client was generated for "windows", but the actual deployment required "rhel-openssl-3.0.x".
Add "rhel-openssl-3.0.x" to `binaryTargets` in the "schema.prisma" file and run `prisma generate` after saving it:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}

Want results from more Discord servers?
Add your server