I’ll be following this path to install Node.js on my Windows machine: Chocolatey CLI > nvm > node.js
First, I downloaded Chocolatey CLI (choco) to install NVM (Node Version Manager). You can see this page for more details. To do this, I run the following command in the PowerShell with Administrator rights.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
If you have forgotten to run the installation without the Administrator permission, like I did.
The post installation says, “WARNING: Setting ChocolateyInstall Environment Variable on USER and not SYSTEM variables. This is due to either non-administrator install OR the process you are running is not being run as an Administrator.”
- Delete the Chocolatey folder under the path
C:\ProgramData\chocolatey - Delete the Chocolatey temporary folder in to remove the installation file
C:\Users\your_user_name\AppData\Local\Temp\chocolatey - Reinstall Chocolatey
You can find more details about the uninstallation at https://docs.chocolatey.org/en-us/choco/uninstallation/
Once Choco is installed, I run the following command to install NVM.
choco install -y nvm
Side note: to upgrade Chocolatey, run
choco upgrade chocolatey
Thankfully, the NVM installation process detected that my computer has Node 6.14.0 (32-bit) installed. I don’t remember when I installed it or what app comes with this node, but NVM offered to manage this version, to which I agree. This means, I would then be able to uninstall it since my previous attempt to uninstall this node has been failed, as it is not listed under the Windows’ Installed Apps.
nvm uninstall 6.14.0
Next, I select the latest Node.js LTS package, which as of this writing is version 24.12.0, by running this command:
nvm install lts
At the end of the installation process, I’m suggested to use the following command if I want to use the newly installed version.
nvm use 24.12.0
Or since this version is an LTS, I can also run
nvm use lts
Finally, along with this LTS version, I install the latest Node.js version (v25), so that I can have options to use any of them. To see all the installed nodes version, I run:
nvm list
Since I have more than one version of Node.js and npm installed, I can switch between them using use command, but I can’t set the global default version to use by running the nvm alias default command as this only works on Mac OS/Linux environment. See https://github.com/coreybutler/nvm-windows/issues/736#issuecomment-1017691732
Notes on nvm alias default command on Mac OS/Linux.
Since the first version installed becomes the default, in my case version 24, this command only works on the subsequent installations. New shells will start with the default version of node.
nvm alias default 25
Apparently, I can’t run nvm alias default lts because this command required a major version (24, 25) or a specific version (24.12.0) of node to peg to.
References
Setting up WordPress local environment
Share your thoughts