Mac solved command not found: compdef

Follow these steps to install nvm using homebrew
https://www.wdiaz.org/how-to-install-nvm-with-homebrew/

Confirm echo $HOME/.nvm returns
/Users/{your username}/.nvm

Now let’s edit zshrc to add nvm bash_completion

vi ~/.zshrc

Add the following lines to the top of the 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

autoload -Uz compinit
compinit

Note: Make sure you add this snippet before any call to compdef else you will still see the error

Reload the terminal and the errors should be gone

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: