WSL2
with Visual Studio CodeRemote development Extension pack on VS Code
docker-compose
WSL
WSL2
following the docsdocker-compose
in WSL
WSL2
based engine in the settings on docker desktop.Resources
on docker desktop.npm
Based on Fiqri Ismail's Medium article:
Use the nodesource
distribution installer:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Find other versions in @nodesource/distributions/deb/
Use apt-get
to install nodejs
:
sudo apt-get install -y nodejs
Verify that node
is working:
node --version
PATH
bash: /mnt/c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
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.
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 before making the following changes.
Open ~/.bashrc
in your editor:
code ~/.bashrc
Append the following line in the end:
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH%
If you still run into the problem with some commands you might wan to consider this approach:
### 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.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing