Node.js is a cross-platform runtime for running server-side (back-end) JavaScript apps outside the browser. This guide describes how to install the Node.js framework and the Node Package Manager (NPM) on Windows.
The official website (https://nodejs.org/en/download/prebuilt-installer) provides an MSI installer for Node.js and NPM. If there are no specific requirements, it is usually recommended to install the LTS (Long Term Support) version of Node.js.
Run the installation from the MSI package with the default settings.
The MSI package contains not only the Node.js framework itself but also the NPM package manager, which is installed by default. The installer will automatically add the paths to the Node.js and NPM directories to the Windows environment variables.
Compiling some of the modules installed via npm may require Python and Visual Studio. You can either let NPM install the required tools automatically via Chocolatey, or install them manually later (https://github.com/nodejs/node-gyp#on-windows).
Once the installation is complete, check that Node.js and npm are installed. Run the following commands to check the tool versions:
node -v
npm -v
It is also possible to install Node.js. using the WinGet package manager (installed by default on Windows 10/11).
winget install OpenJS.NodeJS.LTS
This command will automatically download the latest LTS version of Node.js and silently install it.
Restart the cmd/powershell console to update the paths in the environment variables. Check that node.js and NPM have been successfully installed and that the paths to them have been added to the PATH environment variable:
(Get-ChildItem env:Path).value -split ";"
C:\Program Files\nodejs\ C:\Users\%username%\AppData\Roaming\npm
Or install the Node.js on Windows using the Chocolatey package manager:
Choco install -y nodejs.install
You can use a simple JavaScript script to test how Node.js works. Create a text file hello.js containing the code:
console.log("Hello, world!")
Run the JS script using node.js:
node hello.js
For server deployments, it is recommended to use the NVM (Node Version Manager) to install Node.js and npm.
The easiest way to install NPM is to use the NVM for Windows package ( https://github.com/coreybutler/nvm-windows). Download the nvm-setup.exe
file and run the installation.
To install a specific version of Node.js using NVM, run:
nvm install 21
List installed Node versions:
nvm list
Switch between NodeJS versions:
nvm use 20.11.0
When switching versions, the nvm script replaces the path to the Node.js version in the PATH variable.