'Laravel command not found by ZSH on MacOS

I am getting the error

zsh: command not found: laravel

I tried the other answers from the answered questions but they seem be old and do not work. I am on Mac with macOS Mojave.

I have the following in the ~/.zshrc files

export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/harshamv/.composer/vendor/bin:$PATH"
export PATH="/usr/local/sbin:$PATH"
export PATH="$HOME/.composer/vendor/bin:$PATH"


Solution 1:[1]

I installed Laravel Globally again and it worked

composer global require laravel/installer

Solution 2:[2]

For those who are still struggling in this problem after searching through youtube and stack overflow, I found the solution.

Most likely you can't solve the issue is because Apple changed the terminal from Bash to Zsh as default shell in MacOS Catalina. This is the reason why changing .bash_profile or .bashrc won't work in newer MacOS.

Follow these steps if you are using Catalina:

  1. Open Terminal
  2. Run "nano ~/.zshrc"
  3. Paste: export PATH="$PATH:$HOME/.composer/vendor/bin" , at the last line into the nano editor. (with the quotation mark)
  4. Press "Control + X"
  5. Press "y"
  6. Press "Enter"
  7. Run "source ~/.zshrc"
  8. Run "laravel" to see if the issue solved.

[Bowie Lam]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harsha M V
Solution 2 Abdalla A