[Update on 03 June 2020]
Since Microsoft just released the update which is windows 10 build 2004, and I just convert to WSL 2 without any issue.
Here are the steps to upgrade
[End of Update]
Recently, I was assigned to Angular 7 project, the first thing I thought was how to set up my development environment without impact to existing work, they could be the version of NodeJs, npm packages (i.e. node-gyp), python and so on... Luckily, we can run Linux natively on Windows 10, it's known as Window Subsystem for Linux - WSL in short.
- Although Microsoft has WSL 2, but in this post, I'm going to install WSL 1 since I'm not running Windows Insider version.
- This post assumes that we has already Window Terminal installed.
Let's start with opening Window Terminal as Administrator
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
The simplest way is we can install via Window Store but we may face the problem of drive system got full since it's installed at
%LOCALAPPDATA%\Ubuntu-18.04-LTS\rootfs as default. In order to avoid this problem, we may want to install on Non-System drive, for instance,
E:\_wsl\Ubuntu-18.04-LTS drive. Then follow the below steps
- Create the folder
- Download Ubuntu-18.04-LTS distro, the downloaded file may be
CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.817.0_x64__79rhkp1fndgsc.Appx, then copy to
- Change to
- Change to zip file
move .\CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.817.0_x64__79rhkp1fndgsc.Appx .\Ubuntu-18.04-LTS.zip
- Extract Ubuntu-18.04-LTS.zip
- Then we execute
ubuntu1804.exeinside the folder Ubuntu-18.04-LTS, in this step, we have to provide username and password. If there is no issue, we can see as below
Install node version manager (aka nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
- In this step, I'm going to install nodejs v11.15.0
nvm install 11.15.0
nvm use 11.15.0
sudo apt-get update -y
sudo apt-get install -y node-gyp
npm install -g @firstname.lastname@example.org
cd /mnt/d/ mkdir learning-angular7 cd learning-anguar7 ng new my-app
cd my-app ng serve --open