P
Prismaโ€ข3d ago
Abdul Munim

link local prisma database project into other projects

Question I have two services that is in need of my prisma project that has all the types and prisma client, now I need a way to install it into both projects. My database project only has one file prisma.ts that exports the prisma client, I also need the types of my models as well. my database project package.json { "name": "pricing-oygula-database", "version": "0.0.1", "description": "", "main": "prisma.ts", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "amunim", "license": "ISC", "dependencies": { "@prisma/client": "^5.21.1", "prisma": "^5.21.1", "tsc": "^2.0.4", "typescript": "^5.6.3" } } I tried npm link and then cd into my next.js project to npm link but that does not work. How to reproduce (optional) create 3 folders website some-other-service database Initialize a next.js project in website npm init some-other-service and install express npm i prisma inside database and write a schema.prisma, create prisma.ts file exporting the default prisma client.
4 Replies
Nurul
Nurulโ€ข2d ago
Hello @Abdul Munim ๐Ÿ‘‹ Based on your usecase, I think you are looking for a way to share PrismaClient and the generated types in different projects. The best way to go about this would be to create a private npm package which has all the generated types. Here's an example: https://github.com/igolka97/shared-prisma-client-example
Abdul Munim
Abdul Munimโ€ข2d ago
GitHub
link local prisma database project into other projects ยท prisma pri...
Question I have two services that is in need of my prisma project that has all the types and prisma client, now I need a way to install it into both projects. My database project only has one file ...
Abdul Munim
Abdul Munimโ€ข2d ago
fixed
Nurul
Nurulโ€ข2d ago
Nice! Using Monorepo is also a great way to go about this ๐Ÿ‘ Thanks for taking the time to share your solution. This would be helpful to other users ๐Ÿ™
Want results from more Discord servers?
Add your server