Firebase CLI (command line interface) is a powerful tool provided by Firebase that allows developers to interact with Firebase services from the command line. It simplifies the management and deployment of Firebase resources, making it easier to integrate Firebase services into your Flutter applications.
You can follow the instructions given below to install Firebase CLI.
Install Node.js.
Install Firebase CLI using npm.
Install FlutterFire CLI, especially for Flutter applications.
Login to Firebase and test CLI.
To begin the installation process, you need to install Node.js, which includes npm (node package manager). Npm is required to install and run Firebase CLI and FlutterFire CLI.
Visit the official Node.js website.
Download the Node.js installer suitable for your Windows or macOS version.
Now run the installer, and you can follow the on-screen instructions to complete the installation.
To install Node.js on Linux, you can run the following commands on the terminal.
sudo apt update
sudo apt install nodejs npm
After installation is complete, verify by checking the installed version of node.js by using the following command.
node -v
npm -v
The Firebase CLI requires Node.js v16.13.0 or later.
Once Node.js is installed, you can install Firebase CLI using npm. Follow the commands below in your terminal.
npm install -g firebase-tools
This command installs Firebase CLI globally on your system, making it accessible from any directory using firebase
keyword.
After running the above command, I saw this error npm ERR! Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/firebase-tools'
What do I do?
After installing Firebase CLI, you can install FlutterFire CLI, specifically designed for Flutter apps using Firebase services. Follow the commands below in your terminal or command prompt.
dart pub global activate flutterfire_cli
After running the above command, the flutterfire
command will be available globally.
After running the above command, I saw this error flutterfire: command not found'
What do I do?
After Installation is completed, you have to log in to the Firebase console so that you can manage your projects from CLI using the following command.
firebase login
This command will open a web page where you will provide your credentials to connect to localhost on your machine.
If you are working on a remote machine where accessing localhost is impossible, include the "--no-localhost" flag when running the command.
You can verify that your CLI is working fine by using the following command.
firebase projects:list
This command should list the same projects available at the Firebase console.
You can efficiently utilize Firebase services through the command line, improving your development process, and unlocking the full potential of Firebase features in your Flutter applications.