1

I'm using oh-my-zsh and I would like to use the plugin nvm. It works fine, except for one part, the auto switch to correct node version.

I've set the env variable NVM_AUTOLOAD=1 inside my .zshrc file but it's not working.

Anyone having an idea how to solve that ?

Thanks.

G. Frx
  • 2,350
  • 3
  • 19
  • 31

2 Answers2

9

With the latest oh-my-zsh (at the time of this comment), just need to put zstyle ':omz:plugins:nvm' autoload true before the call to source $ZSH/oh-my-zsh.sh

user20583672
  • 91
  • 1
  • 3
2

SOLUTION

You need to set NVM_AUTOLOAD=1 before the line:

source $ZSH/oh-my-zsh.sh

I had the same problem when I had it at the end of my .zshrc.

WHY IT'S LIKE THAT

In the plugin script it only creates the autoload function and adds it as a hook if NVM_AUTOLOAD is set. But because this is happening at the top level of the script (as opposed to in some function that's run as a hook or something) it will only happen when the plugin is loaded, and I believe the plugins are only loaded at the line source $ZSH/oh-my-zsh.sh. So it has to be set before that line.

ditzy
  • 36
  • 1
  • this is now deprecated. Check this answer for an up-to-date solution : https://stackoverflow.com/a/74549760/5193946 – Younes SADMI Apr 28 '23 at 15:05