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