nvm-sh Frequently Asked Questions (FAQ)
Linux/macOS Version
Add to ~/.bashrc or ~/.zshrc:
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
I've Installed NVM, But the nvm
Command Doesn't Work
This could be caused by several reasons:
- Environment variables not properly set: Make sure the NVM directory has been added to your PATH
- Need to restart the terminal: After installation, close and reopen your terminal or command prompt
- Configuration file not updated: Check if your bash configuration file (
.bashrc
,.bash_profile
,.zshrc
, etc.) includes the NVM initialization code
Usage Issues
Node.js Version Reverts to Default Every Time I Open a New Terminal
This happens because NVM loads the default version in each new terminal session. To solve this problem, you can:
Set a default Node.js version:
bashnvm alias default 14.17.0
Create a
.nvmrc
file in your project directory and runnvm use
in the project directory
Globally Installed Packages Disappear After Switching Node.js Versions
This is normal behavior for NVM. Each Node.js version has its own separate set of global packages. When you switch versions, you can only access the global packages installed for the current version.
Solutions include:
- Installing global packages separately in each Node.js version you need
- Using the
nvm reinstall-packages
command to copy packages from one version to another
SSL Errors When Using nvm install
If you encounter SSL certificate issues, you can try the following methods:
# Windows
nvm install 14.17.0 --insecure
# Linux/macOS
NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 14.17.0
Error When Installing Node.js Version on macOS
You're encountering a Node.js module compilation error, which typically occurs when executing npm install
or yarn install
. Specific error message:
# Error:
/,nym/,cache/src/node-y14.18.0/files/out/Release/obj.target/v8 zlib/deps/v8/third party/zlib/zutil.o] Error 1
make[1]: *** [/Users/.../zutil.o] Error 1
This indicates a failure in compiling the zlib
library for the V8 JavaScript
engine that Node.js
modules depend on.
Solution:
# Install Xcode Command Line Tools
xcode-select --install
# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Python (Python 3 recommended)
brew install python
How to Uninstall NVM?
Linux/macOS
- Delete the NVM directory:
rm -rf "$NVM_DIR"
- Remove NVM-related lines from your shell configuration files (
.bashrc
,.bash_profile
,.zshrc
, etc.), see Installation Guide for details