vscode + wsl2
1. enable wsl2
2. install ubuntu
3.
sudo apt update sudo apt install nodejs sudo apt install npm npm install --global yarn sudo apt install git-all
3.1 ---題外話
遇到了node版本過高導致無法 install 的問題。所以 使用nvm安裝低版本的nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
關閉窗口重新打開,
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
查看version list
nvm ls-remote
nvm install 6.14.4 # or 10.10.0, 8.9.1, etc nvm install node # "node" is an alias for the latest version nvm use node
4. clone the repo
5. npm install under the repo
6. access wsl:Ubuntu via vs-code's Remote tool

7. current issue, seems wsl app can not access windows host api TODO: -- should be fix this
8. 獲取wsl ip 配置
ip route | grep default | awk '{print $3}'
hostname -I | awk '{print $1}'
# 直接放開 `vEthernet (WSL)` 這張網卡的防火墻 New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
9. 如果訪問外部api,則沒有問題了。但是如果想本地debug,那么iis express 無法在局域網內訪問,
安裝ConveyorbyKeyoti, 并且需要注意,wsl2 的內部ip是類似于172.21.127.140這類的,外部主機是172.21.127.1,
所以需要在ConveyorbyKeyoti中進行一下配置映射。
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
10. all work now。 這樣子,在有linebreak-style檢查的項目中就不會 很難受了。畢竟windows下的這種檢查很是煩人。

浙公網安備 33010602011771號