TypeScript deploy "Cannot find module `.prisma/client`"
See original GitHub issueBug 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…
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:24 (14 by maintainers)
Top Results From Across the Web
2 - Stack Overflow
In this case, the Prisma client files will be copied directly to ... this solved `Error: cannot find module : '.prisma/client'.
Read more >Can't find '@prisma/client' after deploying, but it works on dev
Error: Cannot find module '@prisma/client' in netlify functions when using ... I use typescript in my code, so I think it is automatically...
Read more >@prisma/client - npm
Prisma Client is an auto-generated, type-safe and modern JavaScript/TypeScript ORM for Node.js that's tailored to your data.
Read more >Autocompletion in GraphQL resolvers with JavaScript - Prisma
When using GraphQL with TypeScript, you always get autocompletion for the Prisma Client instance in your GraphQL resolvers because then the context object ......
Read more >Search - appsloveworld
In this case, the Prisma client files will be copied directly to resources/app/node_modules ... this solved `Error: cannot find module : '.prisma/client'.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, after a bit more investigation, it turned out, that EB is not allowing any
postinstall
hook to write to the filesystem. There are 2 ways to fix this:1.
.npmrc
Create a
.npmrc
file with this content:unsafe-perm=true
This let’s the postinstall hook write into the filesystem as is the case in a normal npm installation.2. Add
prestart
hookUnfortunately, EB doesn’t run the
postinstall
hook of the main application. However, you can add aprestart
hook that runs prisma generate like so:I suggest using the
prestart
hook 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.