Zige
Zige
Explore posts from servers
PPrisma
Created by Zige on 12/3/2024 in #help-and-questions
Cannot run built code when different prisma client output folder
Hi, I came to this problem when I tried to change the prisma client output folder. No matter if I specify folder in src or not, it is not possible to run the build index.js. When I run it in dev, it works just fine. The build completes just fine (when I omit the --dts tag). But when I want to run it, it always fail on error something like: Error: Dynamic require of "child_process" is not supported or Error: Dynamic require of "fs" is not supported in generator schema: output = "../src/generated-prisma-client" here are my scripts:
"scripts": {
"dev": "nodemon -w src/server -x tsx src/server/index.ts",
"start:tsx": "cross-env NODE_ENV=production tsx src/server/index.ts",
"build:react": "vite build",
"build:server": "tsup",
"build": "npm run build:react && npm run build:server",
"start:node": "node dist/index.js",
},
"scripts": {
"dev": "nodemon -w src/server -x tsx src/server/index.ts",
"start:tsx": "cross-env NODE_ENV=production tsx src/server/index.ts",
"build:react": "vite build",
"build:server": "tsup",
"build": "npm run build:react && npm run build:server",
"start:node": "node dist/index.js",
},
here is my tsup config:
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["./src/server/index.ts"],
format: ["esm"],
outDir: "dist",
minify: true,
splitting: false,
sourcemap: true,
});
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["./src/server/index.ts"],
format: ["esm"],
outDir: "dist",
minify: true,
splitting: false,
sourcemap: true,
});
and here is the tsconfig:
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@prisma-client": ["./src/generated-prisma-client"],
"@prisma-client/*": ["./src/generated-prisma-client/*"]
}
},
"include": ["src/**/*"]
}
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@prisma-client": ["./src/generated-prisma-client"],
"@prisma-client/*": ["./src/generated-prisma-client/*"]
}
},
"include": ["src/**/*"]
}
I believe there is problem in the typescript building config, but honest IDK. Has anyone faced this before? Any suggestion is appreciated.
3 replies