watermelon123
watermelon123

Reputation: 417

Unable to use nvm install on MacOS: 'zsh: command not found: nvm'

I appreciate that this question has been asked several times, but none of the answers have been able to help me.

I am new to working at the terminal, and am trying to install node with nvm on MacOS Catalina. I successfully installed nvm using 'brew install nvm', but when I try to run 'nvm install 10.15.0' I get the error 'zsh: command not found: nvm'.

Running 'brew info nvm' gave me this:

You should create NVM's working directory if it doesn't exist:

  mkdir ~/.nvm

Add the following to ~/.zshrc or your desired shell
configuration file:

  export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.

So, I followed these instructions; I created the NVM working directory and added the configuration to my /.bash_profile shell. Here is my .bash_profile file when run with 'nano .bash_profile':

# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/name/opt/anaconda3/b$
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/name/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/name/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/name/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<


# virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source "$(pyenv which virtualenvwrapper.sh)"

# RabbitMQ
export PATH=/usr/local/sbin:$PATH

export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

I have restarted the terminal, and still nvm install does not work. Honestly, I am a little confused by the .bash_profile file, and wonder if it is something to do with the PATH?

Upvotes: 12

Views: 40407

Answers (1)

Ryan Lafazan
Ryan Lafazan

Reputation: 126

This has been answered many times.

This recent question has a simple and straightforward answer for installing nvm via brew: simple solution

This older question has more in-depth solutions and additional details if you are installing with or without brew: detailed solutions

Upvotes: 6

Related Questions