prisma: TypeScript deploy "Cannot find module `.prisma/client`"
Bug description
When trying to deploy Prisma client to Elastic Beanstalk, I am seeing the following errors:
Error: Cannot find module '.prisma/client'
Require stack:
- /var/app/current/node_modules/@prisma/client/index.js
- /var/app/current/dist/utils/Prisma.js
- /var/app/current/dist/config/passport.js
- /var/app/current/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/var/app/current/node_modules/@prisma/client/index.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/var/app/current/node_modules/@prisma/client/index.js',
'/var/app/current/dist/utils/Prisma.js',
'/var/app/current/dist/config/passport.js',
'/var/app/current/dist/index.js'
]
}
How to reproduce
Follow along this prisma tutorial and attempt to deploy to AWS Elastic Beanstalk
Expected behavior
It to deploy properly.
Prisma information
Package.json :
...
"@prisma/cli": "2.15.0",
"@prisma/client": "2.15.0",
...
tsconfig.json
{
"compilerOptions": {
"lib": ["esnext"],
"outDir": "dist",
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
}
}
I will say I have tried all different variations of tsconfig as well…
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 24 (14 by maintainers)
Commits related to this issue
- deployment: add AWS Elastic Beanstalk notes Fixes https://github.com/prisma/docs/issues/1227 Related: https://github.com/prisma/prisma/issues/5266 — committed to prisma/docs by 2color 3 years ago
- Document AWS Elastic Beanstalk deployment suggestions (#1229) * deployment: add AWS Elastic Beanstalk notes Fixes https://github.com/prisma/docs/issues/1227 Related: https://github.com/prisma/pri... — committed to prisma/docs by deleted user 3 years ago
Ok, after a bit more investigation, it turned out, that EB is not allowing any
postinstallhook to write to the filesystem. There are 2 ways to fix this:1.
.npmrcCreate a
.npmrcfile with this content:unsafe-perm=trueThis let’s the postinstall hook write into the filesystem as is the case in a normal npm installation.2. Add
prestarthookUnfortunately, EB doesn’t run the
postinstallhook of the main application. However, you can add aprestarthook that runs prisma generate like so:I suggest using the
prestarthook to be on the safe side.This is a brand new app so I don’t know but previous versions of Blitz apps worked using prisma so I suspect this is new.
Ok good to know! We’ll let you know here once it’s fixed.
I haven’t tried with 2.14.0 but I certainly can and report back.