Install nvm (Node Version Manager) inside zsh
Sanchita Paul

Sanchita Paul @saanchitapaul

About: Full Stack Web Developer

Joined:
Feb 2, 2022

Install nvm (Node Version Manager) inside zsh

Publish Date: Mar 16 '23
51 5

To install nvm (Node Version Manager) inside zsh, you can follow these steps:

Open your terminal and navigate to your home directory:

bash

cd ~
Enter fullscreen mode Exit fullscreen mode

Clone the nvm repository from GitHub:

bash

git clone https://github.com/nvm-sh/nvm.git .nvm
This will create a hidden directory named .nvm in your home directory.
Enter fullscreen mode Exit fullscreen mode

Open your zsh configuration file:

bash

nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Add the following line to the bottom of the file to source nvm:

bash

source ~/.nvm/nvm.sh
Enter fullscreen mode Exit fullscreen mode

Save and exit the file by pressing Ctrl+X, then Y, then Enter.

Restart your terminal or source your .zshrc file:

bash

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Verify that nvm is installed by running the following command:

bash

nvm --version
Enter fullscreen mode Exit fullscreen mode

You should see the version number of nvm printed to the console.

Now you can use nvm to install and manage different versions of Node.js on your system.

Now you can install your desired version like :

nvm install v16.6.0
Enter fullscreen mode Exit fullscreen mode

Now globally it's using v16.6.0
To check list of nvm we can use:

nvm ls 
Enter fullscreen mode Exit fullscreen mode

And to use specific version we can use this command:

nvm use v16.6.0
Enter fullscreen mode Exit fullscreen mode

Thanks

Comments 5 total

  • Md Zahid Hasan Emran
    Md Zahid Hasan EmranMay 10, 2023

    Saved my time

  • Muhammad Arif
    Muhammad ArifDec 28, 2023

    Time Saved!

  • Sachin
    SachinJan 31, 2024

    Very helpful article @saanchitapaul. This really proved useful when I faced JUST this particular problem using zshell despite logging out or even restarting the system. Very much thankful to you! Keep writing and amazing the community! :)

  • Piotr
    Piotr Apr 24, 2024

    Thank U ! Worked out of the box :)

  • Rafael Lourenço Marques
    Rafael Lourenço MarquesMay 11, 2024

    Thanks!

Add comment