Actually you are trying to perform command of ubuntu/mac on windows.
If you want to install NVM in windows then please refer this step by step guide.
Step by step guide
NVM For Windows
Answer from Dakshesh Baldaniya on Stack OverflowVideos
Is it possible to install a specific version of NVM?
Can I use NVM on other operating systems besides Ubuntu?
What is NVM?
It looks like it's related to installing wget or curl with snap on Ubuntu:
https://github.com/nvm-sh/nvm/issues/2504
Here's what fixed it for me:
sudo snap remove curl
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install node
uninstalling snap curl and installing apt install resolved this for me as well,
sudo snap remove curl
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install node
It looks like it is installed. All OP needs to do is restart the terminal.
In my case, I've installed nvm with this instead
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
Then restarted the terminal, and it is working.
Below will share the full process I've been through to install Node.js in WSL.
First of all, make sure one has WSL installed by following this. In this case OP already did that, so, just in case, would update the system's package
sudo apt-get update
Then, the following will install Node.js on WSL:
Install cURL (a tool used for downloading content from the internet in the command-line)
sudo apt-get install curlInstall nvm (there are alternatives to nvm - see the first note below) (Source)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bashVerify the installation with
command -v nvm(it should outputnvm)Check Node versions available with
nvm ls.Install Node.js.
There are various options to do that. Here will only consider installing:
a) Current stable version (recommended for PRD):
nvm install --ltsb) Current release:
nvm install nodeCheck Node versions available
nvm lsVerify Node.js installation
node --version(ornode -v).Verify npm installation with
npm --version
Notes
- One might have to restart the terminal after each installation.
- Additional trouble shooting notes on Linux.
- There are alternatives to nvm, such as
n,fnm,... (more about it) - Using Git on WSL.
- Helpful VSCode extensions.
- One can also use Node.js with Docker containers remote on WSL. Read more about it.
- For more about it, read Microsoft's official documentation.
I believe this may be because you need to restart your terminal, this is one of the troubleshooting tips given from the NVM github page.
There are not any errors when downloading so it is probably just that the .bashrc file was updated but not ran (you should be able to use source ~/.bashrc instead of restarting)