This installation guide will walk you through the process of installing Node.js on your personal Windows computer. |
|
Node.js is a JavaScript runtime that will allow your computer to execute JavaScript code similar to a web browser.
You will install a version of Linux that will run along your Windows operating system for development purposes. Detailed instructions can be found here.
From the command prompt, where you are running as an administrator, type the following:
wsl --install -d Ubuntu
You will install the Ubuntu distribution of Linux by default. This is the correct version to use.
From the Windows command prompt, update your Ubuntu installation to take advantage of WSL 2. Input this command into the WINDOWS command prompt:
wsl --set-version Ubuntu 2
Once your computer has restarted, you can find "Ubuntu" installed as an app in your Start menu. Launch Ubuntu and allow it to finish its installation.
You will be asked to create a username and password for the administrator of this operating system. These DO NOT need to be the same as the username/password for your Windows OS.
The first thing you should do is ask Ubuntu to install any updates. From the Ubuntu command prompt, type the following:
sudo apt update && sudo apt upgrade
You will be asked to input the password you just created.
(This will probably take a while.)
Node.js is sometimes automatically included with the Ubuntu distribution. Unfortunately, the version that is installed is outdated. So the first thing we have to do now is uninstall the old version.
This is done in two steps: purge, which uninstalls Node.js, and auto-remove which removes any leftover files that no other software needs (now that Node.js has been uninstalled).
Run the following command in the Ubuntu command line window:
sudo apt-get purge --auto-remove nodejs
To install software from the internet, Linux needs to be able to resolve web addresses (URLs). It can do that with a tool called cURL. Install that now by typing this into the Ubuntu command line window:
sudo apt-get install curl
There are several different versions of Node.js, so they have developed software to help you obtain and switch between versions (which is helpful if you are working on multiple projects). That software is called nvm (Node.js Version Manager). Install that now.
(Copy and paste this entire line - it is word-wrapping in the documentation, but it is a single command.)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
CLOSE and restart your Ubuntu application!
Restart Ubuntu by finding it in the Start menu.
Ensure that nvm was installed by entering the command:
command -v nvm
This should return the message "nvm".
You will now use nvm to install the current stable LTS ("long term support") release of Node.js. Input the following command:
nvm install --lts
Verify the version of Node.js that was installed. Run the following command:
node –-version
You should receive a message that "v16.17.0" (or a higher number) is installed.
If you have not already, download and install Visual Studio Code. Choose the correct version for your Windows version and chipset.
Visual Studio code allows you to install a number of extensions that will speed up your development. The Remote - WSL extension will allow you to work with your Ubuntu server while simultaneously editing your files.
Visit the Remote - WSL page and click the green Install button.
Once this is done, you are finished and ready to continue with our class exercises.