question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot bundle Node.js built-in "node:http" while vite build

See original GitHub issue

I am working on Vite v3.0.9 and using node-fetch 3.2.10. I used doc to import node-fetch (see screen) While build I have next issue image

Current Behavior

image

Expected Behavior Successful build

Your Environment

software version
node-fetch 3.2.10
node 18.12.0
npm 8.19.2
Operating System

Additional context

I’ve already tried workaround with replacing node:http into http But than I have the same error but with just http module

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jimmywartingcommented, Oct 27, 2022

Seems like it’s trying to make it a NodeJS dependency free version so that it do not rely on any NodeJS stuff

so even if you only have import fs from 'fs' in your codebase it would fail? maybe you need change some setting to not bundle built in NodeJS core modules?

0reactions
supproductioncommented, Oct 27, 2022

Also maybe it will help Just created minimal repo https://github.com/supproduction/vite-node-fetch

npm i npm run build

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Vite
As Vite does not bundle most of the files, browsers may request many ... This is because Node.js limits request header size to...
Read more >
Node.js v19.3.0 Documentation
All instances contain the built-in Error properties ( message and name ) and: actual <any> Set to the actual argument for methods such...
Read more >
Polyfill Node.js built-in modules with Vite - Medium
A build command that bundles your code with Rollup, pre-configured to output highly optimized static assets for production. It's very similar to Snowpack...
Read more >
Deploying a new nuxt 3 app result to error - Support
Hello, I've created a new nuxt 3 app and tried to delopy it to netlify with github: stoic-fermat-995d10 The build stop when It...
Read more >
How do I resolve "Cannot find module" error using Node.js?
I don't know how typical this is, but faye creates a build directory when it is built and puts a copy of package.json...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found