Score:1

Cannot install nvm, npm or nodejs

es flag

I'm having trouble installing nodejs and npm on my newly installed WSL2. I've set the WSL up according to the instructions from Microsoft and downloaded the Ubuntu program from Windows Store. I tried running both sudo apt-get install npm and sudo apt-get install nodejs but the answer I get is just "Unable to locate package". I googled a little and found that I could install it via nvm using cURL (curl -v -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash), but cURL manages to set up the TCP connection and then promptly just runs without downloading anything, just running a timer on how long it's been going.

What am I doing wrong? My first thought was that I don't have an internet connection, but it should be running on my Windows connection, and as I say, the TCP is connected correctly because I get no connection errors. Any help on this matter is appreciated!

EDIT: I tried running sudo apt update and I get connection errors to archive.ubuntu.com and security.ubuntu.com which I presume is the servers it's supposed to download the packages from. I get no other error messages except for the servers not answering and the connection timing out, however I can ping both servers and get an answer very quickly. Forcing it to use IPv4 instead of IPv6 which was suggested on another site did not work either.

EDIT2: This is a corporate computer (which I am admin on) on my private network, but I will look into it to see if there are any specific settings I have to enable to give my Ubuntu terminal access or even if I have to be on the corporate network.

user535733 avatar
cn flag
Add to your question the complete output of `sudo apt update`
Sara avatar
es flag
The complete output is very long, but the gist of it is that it cannot connect to archive.ubuntu.com or security.ubuntu.com.
user535733 avatar
cn flag
Then your problem is not "cannot install"; your problem seems to be networking-related. What were the *exact* networking errors ? (add those to your Question above, not comments) Please try to be detailed; more detail means better help.
hr flag
Aside from any network issues (which must be resolved first), the packages you are trying to install are in the Universe repository which is likely not enabled by default. See [How do I enable the “Universe” repository?](https://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository)
Sara avatar
es flag
@user535733 It says "could not connect" on all the instances it tried (which is five different servers, four on archive.ubuntu.com and one on security.ubuntu.com). I get no other error messages except that it could not download some files because of the connection errors. The complete output is redundant in this case as there are no specific errors listed. I can however ping both servers and get answer very quickly, and I've tried forcing it to use IPv4 instead of IPv6 and that still gives me a connection error. I'll edit the question above with this info as well.
Sara avatar
es flag
@steeldriver The Universe repository seems to be added already, but thanks anyway!
user535733 avatar
cn flag
Is this, by chance, a school/corporate/enterprise network that may require use of a proxy?
Sara avatar
es flag
@user535733 The network I'm on right now is my private network, but this is a corporate computer. That might be the issue, but I've gotten no information on any proxies or VPN:s that I have to or even could use. I will have to look into it once I'm at the office tomorrow! Thank you!
Score:0
es flag

The answer was a simple one: my firewall was blocking the connection somehow (my guess is that it blocked all outgoing TCP connections that weren't whitelisted). If you have a similar problem it might be a good idea to try to turn off the firewall for a couple of minutes while you install the things you want, or to find a way to let your WSL through if you can't turn it off.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.