---
tags: '@badging/tooling'
---
# Windows Subsystem for Linux 2
## Getting Started
### Using `WSL2` with Visual Studio Code
- Steps
1. Install the [`Remote development Extension pack on VS Code`](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)
2. Once you install the extension, you will see a Remote Development extension icon at the bottom left corner of the VS Code editor.Click on the icon, you will get a pop up with a list of options. Click on the first option "Remote-WSL: New Window" for the default distro or select the "Remote-WSL: New Window using Distro" for a specific distro.
3. Once installed, the VS Code of your Windows machine/desktop will communicate with VS Code server on the Linux side.
## Troubleshooting
## Troubleshooting `docker-compose`
- Steps taken to fix `WSL`
1. Install latest Windows updates
2. Install `WSL2` following the [docs](https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2)
- Steps taken to use `docker-compose` in `WSL`
1. Uninstalled and reinstalled docker desktop on windows 10
2. Enable the `WSL2` based engine in the settings on docker desktop.
3. Enable integration with additional distributions under `Resources` on docker desktop.
## Troubleshooting `npm`
Based on [Fiqri Ismail's Medium article](https://medium.com/@fiqriismail/setup-wsl-on-windows-10-for-your-javascript-development-with-visual-studio-code-f63f75841e5f):
1. Use the `nodesource` distribution installer:
```sh
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
```
> Find other versions in [@nodesource/distributions/deb/](https://github.com/nodesource/distributions/tree/master/deb)
2. Use `apt-get` to install `nodejs`:
```sh
sudo apt-get install -y nodejs
```
3. Verify that `node` is working:
```sh
node --version
```
## Troubleshooting `PATH`
#### If you hit this:
```
bash: /mnt/c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
```
#### First try this:
If you find your `pwd` starts with `/mnt/c/…` and you should `cd ~/` which will take you to your home folder inside `WSL` which you want to be using instead when hacking on code.
#### Then try this:
You are likely hitting a problem with importing your Windows `PATH` environment variable into `WSL2`.
See https://github.com/microsoft/WSL/issues/1890.
> **Important Notice**: Refer to [@microsoft/WSL #1890](https://github.com/microsoft/WSL/issues/1890#issuecomment-423692567) before making the following changes.
1. Open `~/.bashrc` in your editor:
```
code ~/.bashrc
```
2. Append the following line in the end:
```sh
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH%
```
3. If you still run into the problem with some commands you might wan to consider this approach:
```sh
### remove unnecessary Win PATHs
# This can prevent extension-less commands from bleeding into BASH.
# (eg. "ng" would execute the Win bin if "@angular/cli" wasn't installed on Linux.)
#
function path_remove {
# Delete path by parts so we can never accidentally remove sub paths
PATH=${PATH//":$1:"/":"} # delete any instances in the middle
PATH=${PATH/#"$1:"/} # delete any instance at the beginning
PATH=${PATH/%":$1"/} # delete any instance in the at the end
}
path_remove '/mnt/c/Users/me/AppData/Roaming/npm'
path_remove '/mnt/c/Users/me/AppData/Local/Yarn/bin'
path_remove '/mnt/c/Program Files (x86)/Yarn/bin'
path_remove '/mnt/c/Program Files/Git'
path_remove '/mnt/c/Program Files/Git/cmd'
path_remove '/mnt/c/Program Files/nodejs'
path_remove '/mnt/c/OpenSSL-Win32/bin'
path_remove '/mnt/c/Program Files (x86)/Python27'
```
> See this [comment](https://github.com/microsoft/WSL/issues/1890#issuecomment-318802876).