Configure the WSL development environment
In Yanlin, our technical research and development team prefers the Linux environment in the use of the operating system. In order to use the relevant commands of the Linux system in the windows environment to effectively improve our development efficiency, our front-end development The group chose to install WSL (the windows subsystem for Linux). The following is a brief operation record:
- The "Windows Subsystem for Linux" optional feature needs to be enabled first
Open power shell as administrator, use the command
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Need to restart the computer after running
- Install WSL
(For our windows x64 system version requirements: You must be running Windows 10, version 2004 and later (build 19041 and later) or Windows 11 to use the commands below.)
Install WSL command:
Set WSL version
Here we'd better confirm that the WSL version is the WSL2 version, because it has a complete Linux kernel and better system compatibility.
Set the WSL version to 1 or 2, as follows:
wsl --set-version <distribution name> <versionNumber>
Set WSL as default version
wsl --set-default-version 2
wsl -l -v
It is a modern open source Linux operating system suitable for enterprise servers, desktop computers, cloud, and IoT
wsl --set-version Ubuntu-20.04 2
Connect VS code
Install git in Ubuntu, pull your project code.
Install the WSL plugin in VS code, then CTRL+SHIFT+P to open the command panel, then select WSL to open your project directory.
- Installing node and so on cannot be installed under windows. It should be installed directly through the command line in ubuntu.
Here, you must choose the version suitable for your project for both the wsl version and the node version, otherwise unpredictable errors will occur.
Related Reference Links：安装 WSL | Microsoft Learn
The above can run your project on WSL, and you can use the relevant commands of the Linux environment to effectively improve your development efficiency.