Mac solved command not found: compdef

Follow these steps to install nvm using 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_DIR/"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

autoload -Uz 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

1 Comment

  1. Alfredo says:

    In my case I had to edit my ‘.zshrc’ file. The final lines were:

    # Load Angular CLI autocompletion.

    Hope helps.

Leave a Comment

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

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

Facebook photo

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

Connecting to %s