'The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable program

I'm trying to install flutterfire_cli in my root project, so I typed this command:

FirebaseFirestore firestore = FirebaseFirestore.instance;

so after that, this is the output of my console:

PS C:\Users\PC\Desktop\eventually> dart pub global activate flutterfire_cli
Package flutterfire_cli is currently active at version 0.1.1+2.
Resolving dependencies...
The package flutterfire_cli is already activated at newest available version.
To recompile executables, first run `global deactivate flutterfire_cli`.
Installed executable flutterfire.
Warning: Pub installs executables into C:\Users\PC\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.
A web search for "configure windows path" will show you how.
Activated flutterfire_cli 0.1.1+2.

To fix the warning I added C:\Users\PC\AppData\Local\Pub\Cache\bin to my Path in system variables environnement. (but it does not work, I'm still getting the warning)

Next, I'm trying to generate the firebase_options.dart file as the documentation says using this command:

flutterfire configure

But I'm getting an error in the console:

PS C:\Users\PC\Desktop\eventually> flutterfire configure
flutterfire : The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ flutterfire configure
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (flutterfire:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Could anyone tell me what I am missing, why I am getting this error even if the Firebase CLI already installed on my machine?



Solution 1:[1]

As for me, I have done everything correctly and the command works if I run in the Windows command prompt, but it fails to work if I type the command inside the VS code terminal.

So I just killed the terminal and opened it again, then it works.

Or, you can try restarting your machine.

Solution 2:[2]

Even after adding C:\Users\PC\AppData\Local\Pub\Cache\bin to the path for me flutterfire would not work from the command line, the reason being that it actually instally a flutterfire.bat file.

So I use flutterfire.bat in the command line as of now and that is working.

Solution 3:[3]

For Linux/Ubuntu you should do the following:

  1. Open your .bashrc file using the command "sudo nano ~/.bashrc"
  2. Add export PATH="$PATH":"$HOME/.pub-cache/bin" to the end of the file.
  3. Final you can source the file using "source ~/.bashrc"
  4. It should now be able to recognize the file.

Solution 4:[4]

For Mac -> Execute this command:

export PATH="$PATH":"$HOME/.pub-cache/bin"

Solution 5:[5]

Flutter command not found Here is very easy instructions for adding something to your path on Mac, It solved my issues with Flutter and Flutterfire.

Solution 6:[6]

Use command prompt.. not the vsc terminal

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zuhairi Zainuddin
Solution 2 Ali Nasserzadeh
Solution 3 Hillary Omondi
Solution 4 Yusuf
Solution 5 Jussi Tamminen
Solution 6 Kai - Kazuya Ito