Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 663
Ben Carp Avatar asked Apr 19 '18 10:04

Ben Carp


People also ask

Which Ubuntu should I use for WSL?

WSL supports a variety of Linux distributions, including the latest Ubuntu release, Ubuntu 20.04 LTS and Ubuntu 18.04 LTS. You can find them by opening the Microsoft store app and searching for Ubuntu.

How do I change node version to WSL?

To change the version of Node. js you would like to use for a project, create a new project directory mkdir NodeTest , and enter the directory cd NodeTest , then enter nvm use node to switch to the Current version, or nvm use --lts to switch to the LTS version.

Does npm work on Ubuntu?

Node. js and npm packages are available from the default Ubuntu 18.04 repositories. At the time of writing, the version included in the Ubuntu repositories is v8.


2 Answers

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

like image 170
Ashish Verma Avatar answered Oct 24 '22 20:10

Ashish Verma


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
like image 30
Karthik Raja Avatar answered Oct 24 '22 20:10

Karthik Raja