Skip to content

Install NVM

  1. Run the following curl command to download the file and press enter:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
  1. To verify the installation, run:
command -v nvm
  1. You might see an error: “nvm xcrun error invalid active developer path.” To solve this, run:
$ xcode-select --install
  1. After completing step 3, you can check the version of NVM by running:
MacBook-Pro-2:~ eli$ nvm -v
0.39.3
MacBook-Pro-2:~ eli$
  1. Now run nvm ls to see what you’ve got installed. You will get something like:
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
MacBook-Pro-2:~ eli$

2- Now, install the versions you need. For example, to install versions 14 and 16, run:

nvm install 14
nvm install 16

Once you have it, you can check your installed node version like this.

nvm ls

versions

⚠️ Fix: NVM Not Loading Automatically in Terminal

Section titled “⚠️ Fix: NVM Not Loading Automatically in Terminal”

Sometimes after installing NVM (Node Version Manager), you may notice that it’s not available in new terminal sessions, even though the installation completed successfully.

This usually happens because the installation script failed to correctly update your shell configuration file (.zshrc or .bashrc).


During installation, NVM attempts to append the necessary environment variables to your shell config file. However, depending on:

  • Your shell (zsh, bash, etc.)
  • Custom configurations or permission issues
  • Using tools like Oh My Zsh or custom terminal environments

…the required lines might not be added automatically, or may be placed incorrectly.


You need to manually add the required lines to your shell configuration file.

Edit your .zshrc:

Terminal window
nano ~/.zshrc

Add the following at the end of the file:

Terminal window
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Then reload the file:

Terminal window
source ~/.zshrc

Edit your .bashrc:

Terminal window
nano ~/.bashrc

Add the same lines at the end:

Terminal window
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Reload with:

Terminal window
source ~/.bashrc

After applying the changes, open a new terminal and run:

Terminal window
nvm -v

You should now see the installed version, confirming that NVM is loaded correctly every time.