Resolving 'flutterfire' Command Not Recognized Error
This comprehensive guide addresses the common "flutterfire: command not recognized" error that occurs when trying to configure Firebase for Flutter projects on Windows, macOS, and Linux systems.
Problem Overview
When attempting to use the flutterfire configure
command after installing the FlutterFire CLI, users often encounter the error:
flutterfire: The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable program.
This occurs because the FlutterFire CLI installation directory isn't properly added to your system's PATH environment variable, preventing your terminal from locating the flutterfire
executable.
Primary Solution: Add Pub Cache to PATH
The most common solution across all operating systems is to add the Dart Pub cache directory to your system's PATH environment variable.
Windows
Activate FlutterFire CLI:
bashdart pub global activate flutterfire_cli
Add to System PATH:
- Press Windows key + R, type
sysdm.cpl
, and press Enter - Click "Environment Variables"
- Under "System variables", find and select "Path", then click "Edit"
- Click "New" and add:
C:\Users\YOUR_USERNAME\AppData\Local\Pub\Cache\bin
- Replace
YOUR_USERNAME
with your actual Windows username
- Press Windows key + R, type
Restart your terminal or IDE (required for changes to take effect)
macOS/Linux
Activate FlutterFire CLI:
bashdart pub global activate flutterfire_cli
Add to PATH:
bashexport PATH="$PATH":"$HOME/.pub-cache/bin"
Make the change permanent:
- For bash users: Add the export command to
~/.bashrc
- For zsh users: Add the export command to
~/.zshrc
- Run
source ~/.bashrc
orsource ~/.zshrc
to apply changes
- For bash users: Add the export command to
Alternative Solutions
If the primary solution doesn't resolve the issue, try these additional approaches:
1. Restart Terminal/IDE
Sometimes simply restarting your terminal or development environment (VS Code, Android Studio) resolves PATH recognition issues.
2. Use Command Prompt on Windows
If using Git Bash or VS Code terminal, try running the command in Windows Command Prompt instead.
3. Reactivate FlutterFire CLI
Deactivate and reactivate the package to ensure a clean installation:
dart pub global deactivate flutterfire_cli
dart pub global activate flutterfire_cli
4. Use flutterfire.bat on Windows
Instead of flutterfire
, try using the batch file directly:
flutterfire.bat configure
Or navigate to the binary location and run it from there:
cd C:\Users\YOUR_USERNAME\AppData\Local\Pub\Cache\bin
.\flutterfire.bat configure
5. System Restart
After modifying environment variables, a full system restart may be necessary for changes to take effect system-wide.
6. Verify Firebase CLI Installation
Ensure you've installed the Firebase CLI separately from the FlutterFire CLI:
# For npm users
npm install -g firebase-tools
# Or download the standalone binary from:
# https://github.com/firebase/firebase-tools/releases
Platform-Specific Instructions
# Add to ~/.zshrc or ~/.bashrc
echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >> ~/.zshrc
source ~/.zshrc
# Add to ~/.bashrc
echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >> ~/.bashrc
source ~/.bashrc
# Temporary solution for current session
$env:Path += ";C:\Users\$env:USERNAME\AppData\Local\Pub\Cache\bin"
Troubleshooting Common Issues
WARNING
If you encounter JSON parsing errors when running flutterfire configure
, ensure you're logged into Firebase CLI with a valid account and have created a project in the Firebase console.
TIP
Always run flutterfire configure
from your Flutter project's root directory where the pubspec.yaml
file is located.
Verification
To verify that FlutterFire CLI is properly installed and accessible:
flutterfire --version
If successful, this command will display the installed version number of the FlutterFire CLI.
Conclusion
The "flutterfire command not recognized" error typically stems from PATH configuration issues. By adding the Dart Pub cache directory to your system's PATH and ensuring proper installation of both Firebase CLI and FlutterFire CLI, you should be able to successfully configure Firebase for your Flutter projects.
If problems persist, consult the official FlutterFire documentation for the most up-to-date installation and configuration instructions.