Hi all, I am trying to use Prisma in my AWS lambda...
# orm-help
v
Hi all, I am trying to use Prisma in my AWS lambda to connect it to the Planetscale DB, on local it works fine but after I deploy I am getting the following error in the lambda console:
Copy code
"@prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.\nIn case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>",
I have checked and can see
@prisma/client
in the
./node_modules
not sure what is missing
d
You've got to run
prisma generate
to have @prisma/client generated for that environment.
v
I did, here is the output from guthub actions:
Copy code
| npm i --production: > @prisma/client@3.14.0 postinstall /home/runner/work/guerdon/guerdon/server/node_modules/@prisma/client
  | npm i --production: > node scripts/postinstall.js
  | npm i --production: Prisma schema loaded from ../prisma/schema.prisma
  | npm i --production: âś” Generated Prisma Client (3.14.0 | library) to ./../node_modules/@prisma/client in 64ms
  | npm i --production: You can now start using Prisma Client in your code. Reference: <https://pris.ly/d/client>
  | npm i --production: 
  | npm i --production: import { PrismaClient } from '@prisma/client'
  | npm i --production: const prisma = new PrismaClient()
  | npm i --production:
n
v
Yes, but it didn’t work
n
That’s strange, could you create a bug report for it, so that we could debug what’s going wrong?
v
Hi, I am a bit frustrated. I don’t remember how I fixed it but it seems to be broken again.
Getting the following error:
Copy code
{
  "errorType": "Error",
  "errorMessage": "@prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.\nIn case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>",
  "stack": [
    "Error: @prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.",
    "In case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>",
    "    at new PrismaClient (/var/task/node_modules/.prisma/client/index.js:3:11)",
    "    at Object.<anonymous> (/var/task/index.js:90:10)",
    "    at Module._compile (internal/modules/cjs/loader.js:1085:14)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
    "    at Module.load (internal/modules/cjs/loader.js:950:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
    "    at Module.require (internal/modules/cjs/loader.js:974:19)",
    "    at require (internal/modules/cjs/helpers.js:101:18)",
    "    at _tryRequireFile (/var/runtime/UserFunction.js:71:32)",
    "    at _tryRequire (/var/runtime/UserFunction.js:159:20)"
  ]
}
I checked my git history and I made it work by downgrading it to
3.8.1
, I see that its still same but now it produces same error
n
Is this happening to you on the Prisma version 4 or above?
v
The only thing I know of it works for
3.8.1
only, I tried other versions including latest ones but it doesn’t work. Ideally I would like to use the latest version to get the latest features.
n
Would it be possible for you to provide a sample reproduction of this issue?
v
It would be really difficult as it happens when I deploy it to AWS lambda
On inspecting generated client I see this.
Copy code
class PrismaClient {
  constructor() {
    throw new Error(
      `@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
In case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>`,
    )
  }
}

module.exports = {
  PrismaClient,
}