Fraps
Fraps
PPrisma
Created by Fraps on 1/21/2025 in #help-and-questions
Using Prisma inside firebase functions
Hey guys, I have a backend that runs mostly on Firebase/Firestore functions. However, we started migrating some tables to a PostgreSQL DB and I'm trying to use Prisma on Firebase. Connecting locally and deploying are already figured out by using a VPC + pg-pool. The issue is that when deploying the Firebase functions my code can't find the client library that is being generated. My package.json "scripts": { "build": "tsc", "generate-prisma": "npx prisma generate --sql", "deploy": "npm run generate-prisma && firebase deploy --only functions --force", "deploy:rules": "firebase deploy --only firestore:rules", }, My firebase predeploy: "functions": { "predeploy": [ "echo \"$DATABASE_URL\" && npm --prefix \"$RESOURCE_DIR\" run generate-prisma", "npm --prefix \"$RESOURCE_DIR\" run build", "npm --prefix \"$RESOURCE_DIR\" install --production" ], "source": "functions" }, Error that I'm getting during the deployment step: updating Node.js 20 (1st Gen) function ***... step Function failed on loading user code. This is likely due to a bug in the user code. Error message: Provided module can't be loaded. Did you list all required modules in the package.json dependencies? Detailed stack trace: Error: Cannot find module '.prisma/client/sql' Require stack: - /workspace/node_modules/@prisma/client/sql.js - /workspace/lib/slackBots/aua-daily-update.js - /workspace/lib/index.js - /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/loader.js - /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/main.js at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15) Could not load the function, shutting down.. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation. Has anyone gone through this before?
5 replies