Using Prisma with Rollup or Webpack in Node causes a runtime error
See original GitHub issueBug description
I have traced this to node-fetch
v 2.x which is a dependency of the fetch engine.
https://github.com/node-fetch/node-fetch/issues/412
encoding
seems to be a peer dependency for node-fetch
. A bundler like webpack or rollup will include the require and crash at runtime since encoding
is not installed.
Either prisma should upgrade the node-fetch
dependency to v3 which does away with this or include a cautionary note in the README like node-fetch
did : https://github.com/node-fetch/node-fetch/blob/2.x/README.md#bodytextconverted
Other repos depending on node-fetch
2.x also faced a similar issue https://github.com/netlify/create-react-app-lambda/issues/24
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:17 (10 by maintainers)
Top Results From Across the Web
0 - Stack Overflow
After some google research, i figured out how to fix this bug: install custom-webpack ( npm install @angular-builders/custom-webpack ...
Read more >Turbopack, the successor to Webpack - Hacker News
The project is just a small server rendered web app (using Crystal) that I wanted to add papercss, trix, hotwire/stimulus and hotwire/turbo to...
Read more >TypeScript: Cannot use import statement outside a module
Another common cause of the "Cannot use import statement outside a module" error in TypeScript is trying to run a TypeScript file directly...
Read more >How To Solve Module Not Found Can't Resolve 'fs' in Next.js
When we use Next.js, we have a Webpack setup out of the box to bundle our app. In essence, Next.js is a web...
Read more >next js unexpected token export - You.com | The AI Search ...
Please note you should use Node.js even versions for production. ... /benjamin/Developer/tests/prisma-adapter/.next/server/webpack-api-runtime.js (33:42) ...
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
Use case is generating a single asset that I can distribute to serverless environments. without the need to manage things like lambda layers. Also the generated asset is run through a minifier to reduce size and gain marginal improvement in startup perf.
The error is basically that a dependency of prisma has an implicit dependency on a module called
encoding
. This dependency is not installed when installing prisma. Neither is it mentioned in the prisma readme. Under normal circumstances the code path never reaches therequire
for that dependency but when bundled it does causing an error.Ideally considering the reach and popularity of this project, it will be better to not have such implicit dependencies or make assumptions about the modules available at runtime. I suggest to either add a note in the docs or better yet replace this dependency with a more sensible choice.
Ugh, so the README at https://github.com/node-fetch/node-fetch lies to us 😕