Preparing for web development using WSL, I have taken from other sources and condensed it to save some time. This intends to be a quick setup guide, if you want and in-depth explanation go ahead and open the links at the bottom. I do not intend to take credit from them, links will be at the bottom.
How to enable this feature
- Go into "Turn Windows features on or off" and scroll down to Windows Subsystem for Linux and check the box. You will need to restart your PC
- Go to the windows store and search for 'ubuntu' select and install Ubuntu 18.04 LTS
- Now when you search for 'ubuntu' you will be able to launch a new bash terminal
- Setup your username and password
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs
Check your installation by running
node -v
npm -v
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
optional. If you are gonna use global packages runexport PATH="$(yarn global bin):$PATH"
to ensure being able to access them
Restart your terminal now (might not be needed, but I like to do it)
Choose the one that you like the most, just one of these is needed
This is useful to avoid entering your Windows path every time
ln -s /mnt/c/Users/<Insert your username>/<Your folder>/ ~/dev
So it looks something like thisln -s /mnt/c/Users/roberto/Development/ ~/dev
cd ~
nano .profile
- navigate to the bottom of your file and paste the following:
# This allows you to switch between the Ubuntu root and your Windows Root.
# wr evaluates to the absolute path to your Windows user's root.
export wr=~/../../mnt/c/Users/<Windows Username>/<Working Folder>/
# This gives us a quick way of moving directly to the Windows root
alias cdwr='cd "$wr"'
# This brings you to your Windows Working directory immediatly when you open a new terminal.
cdwr
- Close and save the file
- Restart your terminal and you should be at your root folder
Asumming you have VSCode already installed
Remember that since VSCode requires a GUI, you must install it through Windows
Open a new terminal and run code .
This will open a VSCode windows inside your working directory.
You are now ready to start doing npm init
or yarn init
I almost forgot setup VSCode to use WSL as default terminal.
- Open VSCode
- Open the command palette
ctrl + shift + p
- Type default shell
- Select WSL Bash