'flutterfire' or 'firebase' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
7 min

banner

# Table of Contents

  1. 'flutterfire' is not recognized as an internal or external command
  2. 'firebase' is not recognized as an internal or external command
  3. firebase: command not found error

# 'flutterfire' is not recognized as an internal or external command

The error "'flutterfire' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:

  1. Not having the Firebase or FlutterFire CLI installed on your machine.
  2. Not having the Pub executable in your system's PATH environment variable.

flutterfire is not recognized as internal or external command

Open CMD and run the following command to install the Firebase CLI.

cmd
npm install -g firebase-tools

npm install firebase tools

If you get a permissions error when running the command, you have to run CMD as an administrator.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Run the following command.
cmd
npm install -g firebase-tools

The next step is to install the FlutterFire CLI by running the following command from any directory.

cmd
dart pub global activate flutterfire_cli

install 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.

flutterfire warning message

NOTE: if you are on macOS, run the following command in bash to set the environment variable.

bash
# ๐Ÿ‘‡๏ธ 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.

cmd
# ๐Ÿ‘‡๏ธ 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:

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. You can either click "New" and then "Browse" and navigate to the path or paste it directly.

click new browse

cmd
# ๐Ÿ‘‡๏ธ 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.

path to flutterfire

  1. Once the path is added, confirm the changes by clicking on the "OK" button twice.

path to flutterfire added

  1. Close your Command prompt application and then reopen it.
Note that you must restart your Command prompt shell for the changes to take effect.

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.

cli
flutterfire --version

flutterfire command works

You can use the firebase login command to log into Firebase using your Google account.

cmd
firebase login

You can navigate to your Flutter project directory and run the flutterfire configure command to start the app configuration workflow.

cmd
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:

  1. You have the Firebase and FlutterFire CLI installed on your machine.
  2. You have the Pub executable in your system's PATH environment variable.

# 'firebase' is not recognized as an internal or external command

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.

shell
# ๐Ÿ‘‡๏ธ install the firebase CLI globally npm install -g firebase-tools # ๐Ÿ‘‡๏ธ get package version firebase --version firebase help
If the global installation of Firebase fails, you have to open your shell as an administrator or run the command prefixed with sudo.
shell
# ๐Ÿ‘‡๏ธ 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.

# Update your PATH environment variable

If that didn't help, run the following command:

shell
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 you add the output from the command to your PATH environment variable, you have to restart any open command prompts before it takes effect.

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:

  1. Open the start search and type in env and then click "Edit the system environment variables"
  2. Then click "Environment Variables"
  3. Edit the 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 add the output from the command to your PATH environment variable, you have to restart any open command prompts before it takes effect.

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.

shell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Make sure to open your PowerShell as an administrator before you run the 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.

During the installation, you might get a prompt for whether you want to automatically update the PATH environment variable on your system, make sure to tick the option.
shell
# ๐Ÿ‘‡๏ธ install firebase CLI globally npm install -g firebase-tools # ๐Ÿ‘‡๏ธ get package version firebase --version firebase help
If the global installation of 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.

# firebase: command not found error [Solved]

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.

command not found firebase

Open your terminal and install the Firebase cli globally by running the following command.

shell
# ๐Ÿ‘‡๏ธ install firebase CLI globally npm install -g firebase-tools # ๐Ÿ‘‡๏ธ get package version firebase --version firebase help
If the global installation of Firebase fails, you might have to run the command prefixed with sudo.
shell
# ๐Ÿ‘‡๏ธ 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:

shell
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 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 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:

shell
# 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.

~/.bashrc
# ๐Ÿ‘‡๏ธ make sure to update the path with the output # from the command export PATH="/usr/local/share/npm/bin:$PATH"
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 the Firebase CLI globally by running npm install -g firebase-tools.

During the installation, you might get a prompt for whether you want to automatically update the PATH environment variable on your system, make sure to tick the option.
shell
# ๐Ÿ‘‡๏ธ 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.

shell
# ๐Ÿ‘‡๏ธ 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.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev