NodeJS and NPM connectivity issues on Kubuntu 24 with Docker and VirtualBox

I'm having a strange problem with NodeJS and NPM on my Kubuntu 24 setup. I'm using nvm 0.40.1, node 22.14.0, and npm 10.9.2. When I try to install packages, I keep getting ETIMEDOUT errors. I've tried everything I could find online, but nothing worked.

I made a simple script to check https://registry.npmjs.org and it's giving me a bunch of Aggregate Errors. It's weird because I can access other websites like Google and Microsoft just fine.

Here's what I've found:
- It doesn't work in VirtualBox 7 with Debian 12 using NAT networking
- It works in VirtualBox 7 with Debian 12 using bridge networking
- It works in Docker with different LTS versions (18/20/22)

I'm really confused. Any ideas what could be causing this? Has anyone run into something similar?

Here's a snippet of the error I'm getting:

```javascript
const fetch = require('node-fetch');

fetch('https://registry.npmjs.org/moment')
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(err => console.error('Error:', err));

This gives me ETIMEDOUT for IPv4 and ENETUNREACH for IPv6. Any help would be awesome!

I’ve encountered similar issues before, and it seems you’re dealing with a network configuration problem. Since it works in Docker and with bridge networking in VirtualBox but not with NAT, I suspect the issue involves your DNS or firewall settings.

You might want to check your /etc/resolv.conf to ensure that your DNS servers are correctly set and consider trying a different DNS server such as Google’s (8.8.8.8) or Cloudflare’s (1.1.1.1). Also, temporarily disabling your firewall could help determine if it’s interfering with your connections. If you’re behind a proxy, make sure your npm settings are properly configured.

If these suggestions do not resolve the issue, using a network capture tool like Wireshark might reveal more details about what’s happening during these timeout errors. Additionally, trying a VPN could bypass potential ISP-related problems.

sounds like a dns issue mate. try flushing ur dns cache and adding some public dns servers like 8.8.8.8 to ur network settings. also check if ur using any proxy or vpn thats messing with the connection. if nothing works, maybe try a different node version or reinstall npm. good luck!