How to Install and Switch Between Node.js and npm Versions with nvm on Windows
- 開発環境
- JavaScript
- Windows
Note: The screenshots in this article were captured in a Japanese-language Windows environment. Menu and setting names may differ slightly in an English-language installation.
If you have already installed nvm-windows, you can install and switch to Node.js from PowerShell. Here, using Node.js 22.12.0 as a verification example, we'll walk through nvm install and nvm use alongside their actual output, up through version confirmation. We'll also isolate the cause when only npm -v fails to run.
| Verification items | Content |
|---|---|
| Target OS/shell | Windows 10/11、Windows PowerShell |
| Version used | nvm-windows 1.2.2、Node.js 22.12.0、npm 10.9.0 |
What you can learn from this article
If you have a Windows PC with nvm installed, you can use any version of Node.js/npm by running nvm install then nvm use in that order. In this article, we will use Node.js 22.12.0 and npm 10.9.0 as examples and explain how to isolate when only npm is not working with PowerShell.
What is nvm and why Node.js version control is necessary?
nvm (Node Version Manager) is a version control tool that allows multiple versions of Node.js to coexist on one PC and switch between them with a single command.
- Even if the Node.js version required for each project is different, there is no need to change the installer from the official website each time.
- It only takes two commands: download with
nvm install <version>, then switch withnvm use <version>. - The version of nvm used in this article is
1.2.2(Windows version of nvm-windows).
Preliminary confirmation: Check the installation status of nvm
Before installing Node.js, check whether nvm itself is installed correctly with nvm -v.
1. Open PowerShell and run the following command:
nvm -v
2. If the version number is displayed as the execution result, NVM has been installed successfully.
PS C:\Users\username> nvm -v
1.2.2

If you get a response like 1.2.2, you can proceed to the next Node.js installation step. If the version is not displayed and an error occurs, nvm-windows itself may not be installed, or the PATH may not be reflected yet. First check "How to install nvm-windows | Compatible with Windows 10/11".
To avoid permission errors when nvm install and nvm use operate symbolic links afterward, run Windows Terminal or PowerShell as an administrator.
Step 1: Install Node.js with nvm
nvm install <version number> A single command will download and extract the specified version of Node.js.
Check installable versions (optional)
If you are not sure which version you want to install, you can check the list of Node.js versions currently available for installation with the nvm list available command:
nvm list available
In the list, Current, LTS (long-term support version), Old Stable, and Old LTS systems are displayed along with the version number. For long-term operation, it is standard to use an LTS version supported by the application you are using. The 22.12.0 used below is a verification example to show screens and command output, and isn't necessarily the latest or the right choice for every project. Substitute the actual version number to suit your project's requirements.
1. Execute the following command in PowerShell to install the target version (Node.js 22.12.0 in this article's execution example).
nvm install 22.12.0
2. The download and extraction process will proceed as follows, and the installation is complete when "Installation complete." is displayed.
PS C:\Users\username> nvm install 22.12.0
Downloading node.js version 22.12.0 (64-bit)...
Extracting node and npm...
Complete
Installation complete.
If you want to use this version, type:
nvm use 22.12.0

3. As the message indicates, the node command cannot be used yet at this point. Before proceeding to step 3 to enable it, check the installed version in step 2 below.
Step 2: Check installed version (nvm ls)
nvm ls You can check the list of Node.js versions installed on your PC using the command.
1. Run the following command:
nvm ls
2. Verify that the version you installed in step 1 is displayed in the list.
PS C:\Users\username> nvm ls
22.12.0

If you have multiple versions installed, you can select from all versions in this list and use nvm use to switch which one is currently active.
Why does "node -v" result in an error immediately after "nvm install"
This is because nvm install only downloads and extracts Node.js — it doesn't activate the version for actual use.
Immediately after installation, if you run node -v, you'll get a command-not-found error like this:
PS C:\Users\username> node -v
node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ node -v
+ ~~~~
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

To resolve this error, follow step 3 below and run nvm use for the version to activate it.
Step 3: Activate Node.js version (nvm use)
nvm use <version number> When executed, the reference destination of the symbolic link managed by nvm-windows will be switched and the selected Node.js will be enabled. The selection state is not limited to the current PowerShell and persists across restarts.
1. Activate the version you installed in step 1 with the following command:
nvm use 22.12.0
2. If "Now using node v22.12.0 (64-bit)" is displayed, the switch is complete.
PS C:\Users\username> nvm use 22.12.0
Now using node v22.12.0 (64-bit)

3. Run node -v again and check that the version is displayed correctly.
PS C:\Users\username> node -v
v22.12.0

Node.js itself is now usable, but if you continue to run npm commands, another error may occur. This will be dealt with in step 4 below.
Step 4: Resolve the error that npm command cannot be executed
Depending on the Windows PowerShell execution policy, npm.ps1 may be blocked. First check the behavior without changing the execution policy, then change the setting for the current user only if necessary.
1. After node -v succeeds, running npm -v may produce a security error similar to the following:
PS C:\Users\username> npm -v
npm : File C:\nvm4w\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ npm -v
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

2. Node.js includes both npm.ps1 and npm.cmd. PowerShell resolves npm to npm.ps1, and its execution is blocked, so first try the following command: if npm.cmd -v shows a version number, Node.js and npm are fine. You can continue using npm.cmd without changing the execution policy.
3. If you want to keep using the short npm command, check the current settings.
Get-ExecutionPolicy -List
4. If you want to understand and change the settings on a personally owned PC, run the following only for the current user:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
5. If a confirmation prompt appears, enter Y (Yes). After changing the setting, run npm -v again and verify that the version is displayed.
PS C:\Users\username> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
PS C:\Users\username> npm -v
10.9.0

Now both node -v and npm -v can be executed successfully, and the Node.js/npm environment setup is complete.
On managed terminals at companies, schools, etc., the organization's group policy may take precedence. Please do not change settings without the administrator's permission, and check with your system administrator. If you want to clear the value set for the current user, run:
Set-ExecutionPolicy Undefined -Scope CurrentUser
Why do I get execution policy errors?
Windows PowerShell has execution policies that control the conditions under which scripts can run. When npm.ps1 — resolved when you run npm — doesn't meet the current policy conditions, a PSSecurityException occurs. You can check the scope and priority of execution policies in the official explanation on Microsoft Learn. RemoteSigned allows locally created scripts to run unsigned, while generally requiring scripts obtained from the Internet to be signed by a trusted publisher. Adding -Scope CurrentUser limits the change to only the currently logged-in user. However, in some cases the execution policy is not itself a security boundary, and can be superseded by the organization's policy.
Reference materials
- nvm-windows official README
- Node.js 22.12.0 release information
- About PowerShell execution policies (Microsoft Learn)
Summary
| procedure | command | Execution result |
|---|---|---|
| Check nvm version | nvm -v | 1.2.2 |
| Install Node.js | nvm install 22.12.0 | Download and extraction completed |
| Check the installed list | nvm ls | 22.12.0 |
| Enabling the version | nvm use 22.12.0 | Now using node v22.12.0 (64-bit) |
| Check Node.js version | node -v | v22.12.0 |
| Check alternative npm commands | npm.cmd -v | Check if npm itself is working |
| Change execution policy (only if necessary) | Set-ExecutionPolicy RemoteSigned -Scope CurrentUser | Set to current user |
| Check npm version | npm -v | 10.9.0 |
Setting up Node.js/npm using nvm comes down to two basic commands: nvm install then nvm use. If only npm doesn't work, don't change the security settings right away — isolate the cause with npm.cmd -v first, then choose the response you actually need.
Related Articles
-
How to Install nvm-windows on Windows 10 and 11
-
How to Install XAMPP for Windows: Apache, MariaDB, and PHP
-
How to Install VS Code on Windows 10 and 11
-
How to Set the XAMPP root Password to root to Match MAMP
-
How to Configure AllowOverride in Apache and Enable .htaccess
-
Why Commands After npm Do Not Run in Windows Batch Files and How to Use call