DEV Community

Sanchita Paul
Sanchita Paul

Posted on

Install nvm (Node Version Manager) inside zsh

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

Top comments (5)

Collapse
 
sachinbhatt profile image
Sachin

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! :)

Collapse
 
zahidhasanemran profile image
Md Zahid Hasan Emran

Saved my time

Collapse
 
marif0025 profile image
Muhammad Arif

Time Saved!

Collapse
 
petertomas profile image
Piotr

Thank U ! Worked out of the box :)

Collapse
 
rafaellmarques profile image
Rafael Lourenço Marques

Thanks!