MacOS Mojave下ZSH提示laravel: command not found问题求助
Hey there, let's work through this Laravel command issue you're facing. I've dealt with similar PATH-related headaches on macOS before, so here are actionable steps to get it sorted:
First, confirm the Laravel Installer is actually installed
Run this command to check if the Laravel executable exists in your Composer vendor bin directory:ls ~/.composer/vendor/binIf you don't see
laravelin the output, the installer isn't installed yet. Fix that by running:composer global require laravel/installerClean up your duplicate PATH entries
Your~/.zshrchas repeated entries for your Composer vendor bin path (both/Users/harshamv/.composer/vendor/binand$HOME/.composer/vendor/binare the same location). While this doesn't break things, it's messy and can lead to confusion. Replace those three PATH lines with a single, consolidated one:export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:$HOME/.composer/vendor/bin:$PATH"Refresh your ZSH configuration
After editing~/.zshrc, you need to load the new config immediately. Run:source ~/.zshrcAlternatively, close and reopen your terminal to make sure changes stick.
Verify your PATH is correctly set
Double-check that your Composer vendor bin path is in your active PATH by running:echo $PATHLook for
/Users/harshamv/.composer/vendor/binin the output—if it's missing, go back and confirm your~/.zshrcedits were saved correctly.Fix file permissions if needed
Sometimes the Laravel executable might lack the necessary run permissions. Fix that with:chmod +x ~/.composer/vendor/bin/laravelTemporary workaround if all else fails
While we want the globallaravelcommand working, you can still create a new Laravel project directly via Composer in the meantime:composer create-project laravel/laravel your-project-name
内容的提问来源于stack exchange,提问作者Harsha M V

