prisma: Broken on Next.js 10.2.0 which uses Webpack 5 when running a custom server to support HTTPS locally
Bug description
When I upgrade Next.js to 10.2.0 which uses Webpack 5 and then run node server.js
to run my app locally using HTTPS, I get this error:
error - ./prisma/client/runtime/index.js:24474:15
Module not found: Can't resolve '_http_common'
24472 | var require_http_parser = __commonJS2((exports2, module2) => {
24473 | "use strict";
> 24474 | var common = require("_http_common");
| ^
24475 | if (common.HTTPParser) {
24476 | module2.exports = common.HTTPParser;
24477 | } else {
How to reproduce
Typically you run Next.js apps locally by running npm run dev
and that’s it, but if you want to use HTTPS locally then you have to do something a bit different which involves creating a file usually called “server.js” which attaches the SSL certificate and then runs the server. I have no idea if this particularly issue is related to that or if it would happen without HTTPS, as I only use this method now. I’m hoping the error message alone might make the issue apparent to anyone who understands what it’s saying, and why Webpack 5 would cause this.
Expected behavior
Everything works just as it would on Next.js <10.2.0 / Webpack 4.
Environment & setup
- OS: macOS Big Sur
- Database: MySQL / Amazon Aurora
- Node.js version: 14.16.0
- Prisma version:
prisma : 2.22.0
@prisma/client : 2.22.0
Current platform : darwin
Query Engine : query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 60cc71d884972ab4e897f0277c4b84383dddaf6c
Studio : 0.379.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 26 (12 by maintainers)
@gavrichards If it helps I upgraded to nextjs 11.1.0 / webpack 5, prisma 2.30.0 and this next.config.js trick still works with node 14.x:
PS: a full config is here https://github.com/belgattitude/nextjs-monorepo-example/blob/main/apps/web-app/next.config.js#L127
For what it’s worth, I simply needed to remove
target: "serverless"
from next.config.js.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 @gavrichards @belgattitude @finnatsea)
@gavrichards yes seems working fine without 😄
Test here: https://github.com/belgattitude/nextjs-monorepo-example/pull/327
Ok I updated to Prisma
2.30.0
and Next11.1.0
and everything’s working ok. 🤯 I tried the next.config.js trick that @belgattitude mentioned but it doesn’t seem to be needed so I’ve left it out. The one thing I did need to change was to dropoutput = "./client"
from schema.prisma. I presume this was necessary when I started the project, but it doesn’t seem to be anymore. This is presumably what was causing the issue @millsp was unable to reproduce. I’ll let you know if I come across any other issues, but everything appears good so far. I’m confused because I’m not using2.30.0-integration-undici-4.2
, just the regular version.@millsp thanks, I gave it a try. I got this error: