添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

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?

the error means C:\Users\PC\AppData\Local\Pub\Cache\bin is still not detected in the path, have you tried closing and reopening the console/vs code/restarting the computer? – h8moss Dec 12, 2021 at 5:52 Right after adding path to the PATH var, this happened to me on Android Studio's Terminal window. I tried the command on a fresh cmd window and it worked. – Erdi Dec 18, 2021 at 4:50 Not to be rude, but how is the answer that's accepted... accepted? It doesn't diagnose the issue. Props to h8mossm Erdi, and Brandon Pillay for suggesting the restarts. That's all it took. I personally tried "Exit" in the terminal, then restarting it, but the entire IDE needed to be restarted. – FoxDonut Mar 3 at 23:42

Go through this doc very carefully: https://firebase.flutter.dev/docs/cli/

Step 1: Install Firebase CLI

Step 2: Install FlutterFire CLI with this command dart pub global activate flutterfire_cli

While doing this you must notice the following warning

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.

This means you need to add C:\Users\*username*\AppData\Local\Pub\Cache\bin into your System's environment path.

Step 3: Now flutterfire configure should work.

If still not working play with Firebase commands

dart pub global activate flutterfire_cli

  • Type env into Windows search and open Edit the system environment variables --> Environment variables --> System variables( the one on the bottom of the window) --> Double click on Path --> New and enter this:

    C:\Users\PutHereYourUsername\AppData\Local\Pub\Cache\bin

  • flutterfire configure command should work now - close and open again command prompt or other terminal. Sometimes there is a problem with other editors and terminals where flutterfire configure still does not work. In that case open Command Prompt and it works there for sure.

    I also had to restart VSCode for it to work. Closing and reopening the integrated termincal wasn't enough. – Jean-Marie Dalmasso Jan 6 at 19:08

    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.

    You're right; killing the terminal and opening a new one fixed it, after I also added "C:\Users\PC\AppData\Local\Pub\Cache\bin" to path. Also, the installation of the official Firebase CLI is required, it can be found at firebase.google.com/docs/cli#install_the_firebase_cli – davidn Jan 10, 2022 at 15:20 It appears that installing the Firebase CLI binary file does not work, you have to use the npm command which requires node installed. Check out stackoverflow.com/questions/70410843/… – davidn Jan 10, 2022 at 16:42

    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.

    For Linux/Ubuntu run this command in the terminal,

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

    Which you will also notice in the terminal when you run the command ↓.

    dart pub global activate flutterfire_cli

    For Linux/Ubuntu you should do the following:

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

    dart pub global activate flutterfire_cli
    export PATH="$PATH":"$HOME/.pub-cache/bin"
    
  • Run: flutterfire --version

  • If you get a version number, flutterfire has been installed successfully

    This was the hack i used to solve mine. I copied and pasted the C:\Users\PC\AppData\Local\Pub\Cache\bin in my folder search bar to enter the folder, note I could not find any folder called AppData, but when I pasted it on the folder search it did take me to the bin folder.

    In the bin folder, you will find a file called flutterfire.bat. Copy and paste the flutterfire.bat file in the root of your project and then run the .\flutterfire configure command. Please do note the dot (.) and forward-slash (\). You need to add it to work.

  •