'Installing NPM/Node on Bash on Ubuntu on Windows (WSL). What architecture does Ubuntu/Bash use?

I'm using Bash on Ubuntu on Windows as the command line tool.

I need to install Node and NPM, and on the download page for unix I need to choose between 5 different options: 32bits, 64 bits, ArmV6, ArmV7, Armv8. Arms themselves are either 32 or 64 bit so this left me a confused.

Are Arm versions meant for mobile devices? I couldn't find Bash/Ubuntu in any directory, and not in the 64 bit program directory.

If my Windows is 64 bit, can I assume that Bash/Ubuntu will be 64 bits as well, and that that is the right file to download?



Solution 1:[1]

To install node and npm in Ubuntu on WSL you need to install nvm. It doesn't work with apt-install

  1. Install NVM

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

  1. Edit ~/.bashrc or ~/.zshrc depending on the Linux Shell you're using and add the following at the bottom

export NVM_DIR="/home/yourusername/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Now restart bash, and then run

nvm install node

That will install the latest, if you wish to install a specific version

nvm install v6.11.5

You're all set.

Credit : https://winsmarts.com/how-to-install-node-on-linux-on-windows-wsl-65069ea5f83d

Solution 2:[2]

uname -a

Run the above command in WSl.

If it is 64 bit it will display the following

Linux Karthik-Pc 4.4.0-17134-Microsoft #112-Microsoft Thu Jun 07 22:57:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux

If it is 32 bit then it will display

Linux Karthik-Pc 4.4.0-17134-Microsoft #112-Microsoft Thu Jun 07 22:57:00 PST 2018 i686 i686 i686 GNU/Linux

Btw you can easily download node and npm in wsl from apt.

apt-get install -y nodejs

Solution 3:[3]

According to the link of this comment without NVM

curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs

As of december 2021, it results in:

? tik ~ # npm -v
8.1.4
? tik ~ # node -v
v17.2.0

Solution 4:[4]

Try to upgrade all your plugins in apk. Run the below command in WSl.

sudo apt-get update && sudo apt-get upgrade

Solution 5:[5]

You need to update the WSL packages and repositories for you to get nodejs. Use the following set of commands to accomplish the same:

sudo apt update
sudo apt upgrade -y
sudo apt install nodejs -y

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ashish Verma
Solution 2 Karthik Raja
Solution 3 Timo
Solution 4 Larry
Solution 5 DharmanBot