flutterfirebasefirebase-tools

Error "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;

After that, this is the console session (PowerShell):

cd C:\Users\PC\Desktop\eventually
dart pub global activate flutterfire_cli

Output:

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 environment variable in the system variables environment. (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 (PowerShell):

cd C:\Users\PC\Desktop\eventually
flutterfire configure

Output:

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

What am I missing? Why am I getting this error even if the Firebase CLI is already installed on my machine?


Solution

  • 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. It would be better if you restart the computer after adding it to the path variable.

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

    Step 3: Now flutterfire configure should work.

    If still not working play with Firebase commands