Node NVM Installation - Windows
Always use "Run as Administrator" when starting the Command Prompt (terminal) in Windows!
01 – Check if Node is already installed #
- Open Command Prompt (a.k.a. terminal) as an administrator.
- Type
node -v
ORnode --version
, press Enter. - If a value is returned, e.g. v18.8.0, then node is already installed.
- If node is present, move to step 01a.
- If not, move to step 02.
01a – If node is installed, clear the node cache #
- The node cache must be cleared before uninstalling node.
- In the terminal, type
npm cache clear --force
, press Enter. - You will receive a warning using –-force, it is okay.
- This may happen quickly or take a minute, be patient.
- Check to make sure it has been cleared.
- Type
npm cache verify
, press Enter. - You should see a report indicating the cache is 0 bytes and has 0 index entries.
01b – When node cache is empty, uninstall node #
- In the windows search tool, type "uninstall", press Enter.
- Using the system tool, locate "Nodejs" in the applications list, single click to select it, then click "Uninstall".
- Wait for the uninstall process to conclude.
01c – Confirm the uninstall #
- Return to terminal, as an administrator, and type "where node", press Enter.
- The message "Could not find files..." should be returned.
02 – Installing Node Version Manager Windows (e.g. NVM Windows) #
- Go to https://github.com/coreybutler/nvm-windows/releases
- Scroll down and find the nvm-setup.exe link and click it.
- Once the download is complete, double-click to start the installation.
- During installation, accept all default options.
02a – Confirm Installation #
- Open the terminal, if closed, as administrator.
- Type
nvm
, press Enter. - A message like "Running version 1.1.12" should appear.
03 – Install the Long Term Support (LTS) version of NodeJS #
- In the terminal, type
nvm install --lts
, press Enter. - A message should appear indicating the version number of node being downloaded.
- When done a message will appear indicating the npm (Node Package Manager) version
number that was installed as part of the node installa5on (e.g. npm v8.19.3 installed successfully).
04 – Use the LTS version of Node #
- In the terminal type "nvm use version number" (e.g.
nvm use 20.11.0
), press Enter.
05 – Installing and using a different Node version #
With NVM Windows installed, if you need to download and use a different version of Nodejs, do the following:
- Open the terminal as an administrator.
- Type "nvm install version number" (e.g. nvm install 14.4.2), press Enter.
- When the installation is done, type "nvm use version number" (e.g. nvm use 14.4.2), press Enter.
06 - List Node Versions Installed on your computer #
- Open the terminal as an administrator.
- Type
nvm ls
, press Enter. - A list of all installed versions of Node, that NVM is tracking, appears.
- To see the current version of Node, type
node -v
, press Enter.
07 - Switch Node Versions #
If you find yourself needing different Node versions for different projects, just switch after opening the project.
- In VS Code, or any tool, open the project.
- Open the terminal and type, "nvm use version number" (appropriate to your required node version), press "Enter".
- You should now be switched to that version of Node.