I have been trying to get nvm to work on my terminal on Mac. I have been following this Tutorial when installing nvm. It gives me this message:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 143k 0 --:--:-- --:--:-- --:--:-- 145k
=> nvm is already installed in /Users/<My profile>/.nvm, trying to update using git
=> => Compressing and cleaning up git repository
=> nvm source string already in /Users/<My profile>/.bash_profile
=> bash_completion source string already in /Users/<My profile>/.bash_profile
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:
/Users/<My Profile>/.nvm/versions/node/v22.11.0/lib
├── [email protected]
=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:
$ nvm use system
$ npm uninstall -g a_module
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
As you can see it says it is installed and after closing the terminal, reopen the terminal and add this command (see below), and use nvm freely, however, when I close the terminal and reopen it next time it mentions that zsh: command not found: nvm
.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
I have tried this command but doesn't seem like a permanent solution:
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
How can I fix this issue?
nvm's installer adds the nescessary setup to .bashrc
. However, the error indicates you're using zsh
.
The solution is to add this setup to your .zshrc
file:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Note you'll have to open a new shell for this to take effect. But after the first time, you should be good to go.