Hello! Apologies if this isn't the right place for...
# orm-help
r
Hello! Apologies if this isn't the right place for this question. I'm working on a small school project that uses postgres and Prisma. We're trying to publish to npm and automate the prisma setup for the user and are having issues getting the install to run correctly. Would love to pick someone's brain on the best way to go about using prisma as a dependency for a library.
r
Hey @Ryan Geddes 👋 Could you elaborate on the issue that you were facing while creating the library locally?
r
hi! thanks for the reply! We are including prisma as a dependency on our student project, which is a basic error logger. It registers node.js errors and uses prisma to save them into a local postgres database. On installation, I was having a difficult time getting prisma to install correctly. I tried using a post install script in our package.json to init, introspect, and generate automatically after running a config file to get the .env information from the user:
"preinstall": "node config.js",    "postinstall": "rm ./prisma/.env && mv ./.env ./prisma/.env && npx prisma init && npx prisma introspect && npx prisma generate",
This didn't work, as prisma detected that a prisma folder already existed in our repo when trying to instantiate the prisma client. The solution I came up with was to delete the prisma folder before publishing to npm and to run the following postinstall script instead:
"preinstall": "node config.js ",    "postinstall": "npx prisma init && rm ./prisma/.env && mv .env ./prisma && npx prisma introspect && npm i @prisma/client && node successpig.js"
The solution was to remove @prisma-client from our dependencies and run 'npm i @prisma/client' in the postinstall script. Really curious to hear if there is a better way to do this.
You can try out our app if you'd like! It's still a work in progress:
I am also very much a beginner, so apologies if I'm missing something obvious here! 🙂
r
Let me check this and get back to you 🙂
This didn’t work, as prisma detected that a prisma folder already existed in our repo when trying to instantiate the prisma client. The solution I came up with was to delete the prisma folder before publishing to npm and to run the following postinstall script instead
This isn’t required as instantiating the Prisma Client doesn’t require deleting the prisma folder. Using Prisma as a dependency for your library would be equivalent to that of using it in an application.
Hey @Ryan Geddes 👋 Did that work?