Last updated: Apr 4, 2024
Reading timeยท7 min
The error "'flutterfire' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:
Open CMD and run the following command to install the Firebase CLI.
npm install -g firebase-tools
To open CMD as an administrator:
Click on the Search bar and type CMD.
Right-click on the Command Prompt application and click "Run as administrator".
npm install -g firebase-tools
The next step is to install the FlutterFire CLI by running the following command from any directory.
dart pub global activate flutterfire_cli
Once the installation is done, a WARNING
message is displayed:
Pub installs executables into
C:\Users\YOUR_USER\AppData\Local\Pub\Cache\bin
, which is not on your path. You can fix that by adding that directory to your system's "Path" environment variable.
NOTE: if you are on macOS, run the following command in bash to set the environment variable.
# ๐๏ธ for macOS export PATH="$PATH":"$HOME/.pub-cache/bin"
For Windows, the path should be the following, but make sure to check the output
of the WARNING
message.
# ๐๏ธ replace YOUR_USER with your actual username C:\Users\YOUR_USER\AppData\Local\Pub\Cache\bin
Once you make note of the path that stores the executables, we have to add it to the PATH environment variable.
To add the path to Pub to your system's PATH environment variable:
# ๐๏ธ Replace YOUR_USER with your actual username C:\Users\YOUR_USER\AppData\Local\Pub\Cache\bin
We are looking for the directory that contains the flutterfire.bat
file.
You might also have to restart your PC, but that's not always necessary.
Open a new Command Prompt and run the flutterfire --version
command to make
sure flutterfire
is installed.
flutterfire --version
You can use the firebase
login command to log into Firebase using your Google
account.
firebase login
You can navigate to your Flutter project directory and run the
flutterfire configure
command to start the app configuration workflow.
flutterfire configure
The flutterfire configure
command will ask you to select the supported
platforms (e.g. iOS, Android, Web) and will create a firebase_options.dart
configuration file in your lib/
directory.
If the error persists, try restarting your PC to make sure you don't have any
stale CMD, PowerShell or IDE sessions and rerun the flutterfire --version
command.
To solve the error "'flutterfire' is not recognized as an internal or external command, operable program or batch file", make sure:
To solve the error "'firebase' is not recognized as an internal or external
command, operable program or batch file", install the firebase-tools
package
globally by running npm install -g firebase-tools
.
Make sure your PATH environment variable is set up correctly.
Open your terminal and install the Firebase CLI globally by running the following command.
# ๐๏ธ install the firebase CLI globally npm install -g firebase-tools # ๐๏ธ get package version firebase --version firebase help
Firebase
fails, you have to open your shell as an administrator or run the command prefixed with sudo
.# ๐๏ธ If you get a permissions error, run with sudo sudo npm install -g firebase-tools firebase --version firebase help
If the error is not resolved, try restarting your terminal.
If that didn't help, run the following command:
npm config get prefix
The command will show you the path where
npm puts your
globally installed packages. The global packages will be in the bin
directory
at the specified path.
Look at the PATH environment variable on your operating system and add the
path that the npm config get prefix
command outputs if it's not already
there.
On Windows, the output of the npm config get prefix
command will look
something like: C:\Users\Your_User_Name\AppData\Roaming\npm
.
If you are on macOS or Linux, click on the following subheading:
To update the PATH on a Windows machine, you have to:
env
and then click "Edit the system
environment variables"Path
variable and add the output you got from the
npm config get prefix
command.The path should look like C:\Users\Your_User_Name\AppData\Roaming\npm
(make
sure to replace the Your_User_name
placeholder with your actual username).
If you get the error "firebase cannot be loaded because running scripts is disabled on this system", open your PowerShell as an administrator and set its execution policy with the Set-ExecutionPolicy command.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-ExecutionPolicy
command.This effectively removes the execution policy of Restricted
, which doesn't
allow us to load configuration files or run scripts.
The Restricted
execution policy is the default for Windows client computers.
If you add the output from the command to your PATH environment variable, you have to restart any open command prompts before it takes effect.
If that doesn't help try to
reinstall Node.js
on your machine and then install firebase
globally by running
npm install -g firebase-tools
.
# ๐๏ธ install firebase CLI globally npm install -g firebase-tools # ๐๏ธ get package version firebase --version firebase help
Firebase
fails, you have to open your shell as an administrator and rerun the commands.Alternatively, you can see how you can fix the permissions error on this page in the official npm docs.
To solve the error "firebase: command not found", install the firebase CLI
package globally by running npm install -g firebase-tools
and restart your
terminal.
If the command fails, run it with sudo
and make sure the correct PATH is set
in your system's environment variable.
Open your terminal and install the Firebase cli globally by running the following command.
# ๐๏ธ install firebase CLI globally npm install -g firebase-tools # ๐๏ธ get package version firebase --version firebase help
Firebase
fails, you might have to run the command prefixed with sudo
.# ๐๏ธ If you get a permissions error, run with sudo sudo npm install -g firebase-tools firebase --version firebase help
If the error is not resolved, try restarting your terminal.
If that doesn't help, run the following command:
npm config get prefix
The command will show you the path where npm
puts your globally installed
packages. The global packages will be in the bin
directory at the specified
path.
Look at the PATH environment variable on your operating system and add the
path that the npm config get prefix
command outputs if it's not already
there.
If that didn't work, try to add the path to the bin
folder (from
npm config get prefix
) to your PATH environment variable and restart your
terminal.
For example, on macOS, you can update your path with the following command:
# make sure `path` matches with `npm config get prefix` export PATH=/usr/local/share/npm/bin:$PATH
And on Windows, the output of the npm config get prefix
command will look
something like: C:\Users\Your_User_Name\AppData\Roaming\npm
.
Edit the environment variable on your machine and add the specified path (replacing the placeholder with your username).
If you are on Linux, you can add the output from the npm config get prefix
command to your .bashrc
file.
# ๐๏ธ make sure to update the path with the output # from the command export PATH="/usr/local/share/npm/bin:$PATH"
If that doesn't help try to reinstall Node.js on your machine and then install
the Firebase CLI globally by running npm install -g firebase-tools
.
# ๐๏ธ install `firebase` CLI globally npm install -g firebase-tools firebase --version firebase help
If the global installation of Firebase
fails, you might have to run the
command prefixed with
sudo.
# ๐๏ธ If you get a permissions error, run with sudo sudo npm install -g firebase-tools firebase --version firebase help
Alternatively, you can see how you can fix the permissions error on this page in the official npm docs.
You can learn more about the related topics by checking out the following tutorials: