nvm-windows Frequently Asked Questions (FAQ)
Common issues and solutions when installing NVM. NVM (Node Version Manager) is a tool for managing Node.js versions, but you may encounter some problems during installation and use. This article summarizes common issues you might face when installing NVM and provides detailed solutions.
General Issues
- Not uninstalling Node.js before installing nvm, causing node and npm to be unavailable after installing nvm.
- After installing Node.js with nvm for the first time, remember to use
nvm use
to switch Node.js versions andnvm on
to enable Node.js version control, otherwise node and npm will not be available.
- After installing Node.js with nvm for the first time, remember to use
- After globally installing npm, you need to close the terminal window and reopen it before you can install cnpm.
- When choosing the installation folder for nvm, avoid folder names with Chinese characters or spaces.
NVM Commands Not Recognized in PowerShell
By default, NVM commands can only be used in Command Prompt (CMD) and are not directly recognized in PowerShell. This is because PowerShell's execution policy restricts script execution.
Problem description:
When entering the nvm
command in PowerShell, it shows "command not recognized".
Solution:
- Check the current execution policy:
Enter the following command in PowerShell to check the current user's execution policy
Get-ExecutionPolicy -List
- Modify the execution policy: Change the current user's execution policy to RemoteSigned to allow local scripts to run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
- Verify if it works: Reopen PowerShell and try running the nvm command to confirm if it works.
Error After Installing Node.js
After installing nvm, if you find that you cannot use a certain version of Node.js and get an error, you might not be able to use the npm command. This could be because Node.js was installed during the download process, but npm installation failed.
Solution:
- Download the Node.js compressed package directly from the Node.js official website.
- Uninstall the Node.js version and reinstall it. That is, run
nvm uninstall xxxx
and thennvm install xxx
again. - Try installing a different Node.js version.
nvm use Not Working
Create a node.js folder in the nvm directory. (Note: We must modify the properties of the nvm folder and nodejs folder, setting full control permissions in the "Properties -> Security" tab)
node -v not working issue
Modify the environment variable path parameters, with NVM_SYMLINK pointing to the newly created node.js path. (As shown in the image below, there are 2 places, top and bottom)
What's the Difference Between NVM and Direct Node.js Installation?
NVM allows you to install and manage multiple Node.js versions on the same system, while directly installing Node.js only allows for one version. With NVM, you can easily switch between different versions, which is useful for testing compatibility or working with projects that require specific Node.js versions.
Is NVM Cross-Platform?
The original NVM (nvm-sh/nvm) is primarily designed for Unix systems (Linux, macOS). For Windows, there is a separate implementation called nvm-windows, which provides similar but not identical functionality. There are subtle differences in commands and behavior between the two.
Which Version of NVM Should I Choose?
- If you use Windows, you should choose nvm-windows
- If you use Linux or macOS, you should choose the original nvm-sh/nvm
- If you use WSL (Windows Subsystem for Linux) on Windows, you should install the original nvm-sh/nvm in the WSL environment
Installation Issues
"Runtime Error R6034" After Installing NVM on Windows
This error is usually related to Visual C++ runtime conflicts. Try the following solutions:
- Reinstall nvm-windows
- Make sure you have the latest version of the Visual C++ Redistributable package
- Try running the command prompt as administrator
Slow or Failed Installation Using Domestic Sources
If you are in mainland China, you may need to set up mirror sources:
Windows Version
nvm npm_mirror https://npmmirror.com/mirrors/npm/
nvm node_mirror https://npmmirror.com/mirrors/node/