prisma: I get "Can't resolve '_http_common'" when I use NestJS with monorepo (webpack)
Bug description
When I try to composite Prisma with NestJS monorepo project I get the error. I can`t use default prisma client output path because my projects use prisma client and each project overrides before generated client files. I try to use custom output path but I get the error. I found some information about the error -> https://github.com/restify/node-restify/issues/794.
How to reproduce
Steps to reproduce the behavior:
- Create new app as monorepo project
- Generate client in custom output path. For example “output = …/src/prisma/client”
- Execute command “build”
- See error “Can’t resolve ‘_http_common’”
Expected behavior
Build happy project
Environment & setup
- OS: Mac OS
- Database: PostgreSQL
- Node.js version: 12.22.1
- Prisma version: 2.21.2
datasource db {
provider = "postgresql"
url = env("MAIN_DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
output = "../src/prisma/client"
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 31 (9 by maintainers)
Commits related to this issue
- try a fix suggested in github: https://github.com/prisma/prisma/issues/6899#issuecomment-849126557 — committed to sumbersarana/sumbersarana.com by zegheim 3 years ago
For me is working to get client generated as below:
Then you can import it from anywhere like:
import {PrismaClient} from '@~internal/prisma'
Hope it helps.
Also sad to report that I didn’t find a workaround other than not upgrading prisma or webpack 😢
But it does look like v4 of unidici is in release candidate stages
Hey everyone, this has been fixed in
@prisma/client@dev
if you want to give it a try. Please let us know if you find anything unexpected. Thanks.(cc @VincentThomas06 @j0hnm4r5 @juanzgc)
I excluded _http_common from webpack. The build completed but when I start my project I get an error “_http_common is not defined”. I created new branch master-webpack for reproduce this case.
webpack.config.js
You’re right, I had to update
@prisma/client
to 3.15.2 (and not justprisma
as I had done previously), and it is working now 👍Hey @Frankitch @VincentThomas06 👋 I think I understood the issue. When you generate to the default location, the client gets generated with a
package.json
in which there is a browser field. This field is used by webpack to bundle for the web (default). But because it’s generated outside of node_modules, we don’t create suchpackage.json
. Maybe for good reasons? Maybe not?The next steps will simple. I’ll need to setup a repro, you’re very welcome to help me there if you already have one. And that is just to make sure we are fixing the right problem. Then, I will let us output a
package.json
in custom locations to and see if webpack/nestjs can pick that up automatically. If that fails, I will provide you with a workaround.Thus, I’m closing this issue about
_http_common
, but don’t worry we will be tracking the work to come via #12607Thanks!
Hey @ahmadalfy, sorry about this. We have a fix ready but that is unfortunately blocked due to memory leak issues. That will need to be prioritized first (and investigated) before we can merge the fix.
@millsp here’s a reproduction repo that clearly shows what’s going on (with instructions): https://github.com/j0hnm4r5/example-prisma-next-auth-monorepo
I really appreciate all your help!