Improve NVM loading speed with ZSH

Background

For some time now, I have noticed that my ZSH prompt is taking a long time to launch before I can run any command... which is quite annoying.

If I install NVM on my macbook with brew and load the binary in the standard way. I get this kind of performance:

These results sometimes reached 0.8s..

Resolution

Here are the results I have now, it's much better!

Here are the steps:

  • Uninstall nvm with Brew: brew uninstall nvm
  • Install the zsh plugin zsh-nvm: https://github.com/lukechilds/zsh-nvm
  • Once installed, enable lazy-loading in your .zshrc: export NVM_LAZY_LOAD=true
  • And enable the plugin in your .zshrc:
plugins=(
  git
  zsh-autosuggestions
  zsh-nvm
)


in NodeJS Posted on May 19, 2021