2021 Linux VM Setup: Part 5 - Windows VS Code Setup & Node.js for Ubuntu 20.04 VM
In this last part of the series, we will configure VS Code and add plugins to allow connection to projects on our Ubuntu virtual machine.
Not much needs to be done to get VS Code to connect to a Linux VM, the method I'm explaining here is via a SSH tunnel.
Open VS Code on Windows.
Most of our plugins will be installed and run on the Linux server, while Windows just hosts the VS Code gui, install the below plugins.
Remote - Containers
Remote - SSH
Remote - SSH: Editing Configuration Files
Next, this is Python specific, to speed up VS Code and minimise files it's monitoring, we need to exclude Python venv folders.
Open settings and search for files.watcherExclude
Add **/.venv/**
to the array
Now, click the bottom-left green connection icon and select Remote-SSH: Connect to Host...
Click + Add New SSH Host...
and enter the connection parameters for example.
ssh matt@10.10.10.30 -A
You'll be asked to enter your SSH password, then a new VS Code session will load.
You can now search for and open project folders on your Linux VM and install plugins. Below is a list of plugins I've installed at setup time.
Docker
ESLint
Git History
markdownlint
Prettier - Code Formatter
Pylance
Python
Node.js
Lastly, let's install Node Version Manager, nvm and install Node.js and npm.
Node packages are getting very popular for scripts and terminal tools, so I think it's worth installing, even if you're not developing with Node.js.
We don't use the Ubuntu apt packages with node as it's using an older LTS version of Node.
# change the 0.37.2 below to whatever is the current latest version
# at https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | zsh
This will insert the nvm script in your .zshrc file
Restart the MS Terminal to see the changes
# list all node version packages, there's a lot
nvm list-remote
# let's just install the latest version, whatever number it is
nvm install node
# set terminal to use this version
nvn use node
# install a different version, in this case the latest LTS release
nvn install --lts
# change terminal to use this one
nvm use -lts
## confirm version changes
node -v
This completes the series of setup tutorials for running a Linux VM on a Windows host. I hope this helps someone with their dev setup.
This is part of a collection of blog posts, detailing my laptop setup preferences.
2021 Linux VM Setup: Part 1 - How to install Ubuntu 20.04 on a laptop with Windows 10 Hyper-V
2021 Linux VM Setup: Part 2 - Setting up Git & Github on Ubuntu 20.04
2021 Linux VM Setup: Part 3 - Docker & Docker-Compose Setup on Ubuntu 20.04
2021 Linux VM Setup: Part 4 - zsh, VS Code & Terminal Customisation on Ubuntu 20.04
2021 Linux VM Setup: Part 5 - Windows VS Code Setup for Ubuntu 20.04 VM