Slow shell startup with Node Version Manager (NVM)

While I was working with some frontend projects I used node and npm tools. The problem is that each projects requires different version of those tools so you need something to manage various versions and switch on demand. Node version manager (nvm) is a great tool for that purpose and I was very satisfied with it.

Unfortunatelly after installing nvm my shell startup became quite slow and it was irritating when I opened new terminal tab. It turned out nvm was responsible for that. As i use frontend tools not very often I decided to load nvm on demand.

I changed a fragment responsible for nvm in my .bash_profile file from this:

. "/usr/local/opt/nvm/nvm.sh"

To that:

load_nvm() {
  . "/usr/local/opt/nvm/nvm.sh"
}

Now when I need node and npm tools i simply run load_nvm and my shell is ready for javascript development.

eanlr@vps ~ $ load_nvm
eanlr@vps ~ $ node -v
v8.9.4

One thought on “Slow shell startup with Node Version Manager (NVM)

Leave a Reply

Your email address will not be published. Required fields are marked *