-
Notifications
You must be signed in to change notification settings - Fork 1.7k
I get "Can't resolve '_http_common'" when I use NestJS with monorepo (webpack) #6899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@kvandake Can you update your node js version to node 14 once? |
@pantharshit00 I try to use node 14.16.1 but I get same error. |
Node 16 does same error. |
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
|
Ok, this looks like known issue #6564. I will recommend you downgrade while we work on a fix. We are waiting for release of v4 of https://github.com/nodejs/undici which will remove the usage of |
Also seeing this -- are you suggesting a webpack or prisma downgrade? |
@LayneHaber I was suggesting to downgrade node js here to 14 LTS |
@LayneHaber @kvandake did you happen to find a workaround in the meantime? I tried running with node 14 LTS (per @pantharshit00 recommendation) but getting the same issue. |
@trivigy I'm in the same boat as you here — if you manage to find a workaround, please share. And I'll do the same! |
@j0hnm4r5 Unfortunately I do not know of a workaround and my current solution was to downgrade to prisma |
Here's a temporary workaround, to add to your module.exports = {
webpack: (config, {isServer}) => {
if (isServer) {
config.externals.push('_http_common');
// config.externals.push('encoding');
}
return config;
},
target: 'serverless',
}; |
Hey @j0hnm4r5, sorry to hear that. Could you find some time to work on a minimal repro, I'll be more than happy to look into it. |
@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! |
@millsp any luck, by chance? |
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 |
Any update on this? I am facing this with version |
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 thanks for the update, I found a work around because I use Nx so all references to Prisma moved to the library of components instead of the nest application. |
For me is working to get client generated as below:
Then you can import it from anywhere like:
Hope it helps. |
I'm using Turborepo and I'm also facing the same issues. Prisma Version: It seems when I import
|
I still have this issue error
|
Do you have a timeline for the following issue: #8842 It would be great to have this sorted so we can begin using Prisma in our monorepo (Turborepo)! 😇 |
In my case, I am not getting the To reproduce it, I started from this prisma blog post project as a base + @prisma/client upgrade to 3.11.0 and dev + set a custom output path. |
Thats funny, i got the same error:
webpack config: module.exports = (options, webpack) => {
const lazyImports = [
'@nestjs/microservices/microservices-module',
'@nestjs/websockets/socket-module',
// Tried fixing the issue with this below
/util/
];
return {
...options,
externals: ['util'],
resolve: {
extensions: ['.ts', '.js', '.json'],
fallback: {
util: require.resolve('util/')
}
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader'
},
{
test: /\.js$/,
exclude: /(node_modules|prisma)/,
use: {
loader: 'swc-loader'
}
}
]
},
plugins: [
...options.plugins,
new webpack.IgnorePlugin({
checkResource: resource => {
if (lazyImports.includes(resource)) {
try {
require.resolve(resource);
} catch (err) {
return true;
}
}
return false;
}
})
]
};
};
|
Hey @Frankitch @VincentThomas06 👋 I think I understood the issue. When you generate to the default location, the client gets generated with a 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 Thus, I'm closing this issue about Thanks! |
@millsp I think you got it wrong. In my project I am generating a client in the node_modules, it works 50% of the time and the other 50% I get the error described in this issue. When it does work, I inspect the built artifacts and there is no package.json. This doesn't seem related to a package.json or generating clients outside of node_modules I verified the problematic line is in fact there during the times it works::
this is also a file that doesn't exist in my project (both when Prisma fails to be generated, and in the cases where Prisma generation is scuffed):
|
|
You're right, I had to update |
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 -> restify/node-restify#794.
How to reproduce
Steps to reproduce the behavior:
Expected behavior
Build happy project
Environment & setup
The text was updated successfully, but these errors were encountered: