This article provides a comprehensive guide to resolving the “laravel command not found” error, a common issue faced by developers after installing the Laravel installer globally using Composer. It outlines the root cause of the problem and offers detailed, platform-specific solutions for macOS, Linux, and Windows, ensuring you can successfully execute Laravel commands from your terminal.
After running:
composer global require laravel/installer
when executing:
laravel
you receive:
-bash: laravel: command not found
The laravel executable is installed in Composer’s global vendor/bin directory (commonly ~/.config/composer/vendor/bin or ~/.composer/vendor/bin), which is not in your PATH. Your shell can’t locate the executable.
composer global config bin-dir --absolute
This outputs something like:
/home/your‑username/.config/composer/vendor/bin
Use this path in the following steps.
If using Bash:
nano ~/.bashrc
If using Zsh:
nano ~/.zshrc
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
(Replace with your actual path from the previous step.)
source ~/.bashrc
or
source ~/.zshrc
laravel --version
echo $SHELL
nano ~/.zshrc
(or ~/.bash_profile)
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
source ~/.zshrc
(or source ~/.bash_profile)
laravel --version
C:\Users\YourUsername\AppData\Roaming\Composer\vendor\bin
Click Edit → New, then paste:
C:\Users\YourUsername\AppData\Roaming\Composer\vendor\bin
laravel --version
# Check Composer installation:
composer --version
# Confirm Laravel installer is installed globally:
composer global show laravel/installer
# Verify your PATH:
echo $PATH
# Confirm the directory contains the Laravel executable:
ls $(composer global config bin-dir --absolute)
If you prefer not to modify your PATH:
npx laravel new project‑name
This will invoke the installer directly without global installation.
Work with our skilled Laravel developers to accelerate your project and boost its performance.
Hire Laravel Developer