Skip to content

nvm-sh Frequently Asked Questions (FAQ)

Linux/macOS Version

Add to ~/.bashrc or ~/.zshrc:

bash
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:

  1. Environment variables not properly set: Make sure the NVM directory has been added to your PATH
  2. Need to restart the terminal: After installation, close and reopen your terminal or command prompt
  3. 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:

  1. Set a default Node.js version:

    bash
    nvm alias default 14.17.0
  2. Create a .nvmrc file in your project directory and run nvm 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:

  1. Installing global packages separately in each Node.js version you need
  2. 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:

bash
# 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:

bash
# 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:

bash
# 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

  1. Delete the NVM directory: rm -rf "$NVM_DIR"
  2. Remove NVM-related lines from your shell configuration files (.bashrc, .bash_profile, .zshrc, etc.), see Installation Guide for details

Built with VitePress