How to set up a firebase project at the local machine

In this blog, let’s see how to set up a firebase project at a local machine.

Image from Firebase


  1. Gmail Account
  2. Create a Project — click here to create a project in google cloud
  3. Visual Studio-Code or any IDE. (am using VS code which my favorite editor)
  4. FireStore (Database) as NO SQL — click here on how to set up FireStore database
  5. NPM — node.js

Assume, we have all the above pre-requisites in our local machine.

We must install Firebase CLI tools in our local machine using few npm commands:
1. npm install -g firebase-tools — this command provides to access firebase

2. After install firebase-tools — now we can access the firebase and create cloud functions

3. Type this command “firebase login” in VS Code Terminal and it will take us to log in with our Gmail account. Enter our credentials when it prompts.

To this demo purpose, I have created a folder in my local machine and open with VS Code editor

After successful login, we shall get the below message

Now, we can initialize the firebase project using below command
4. Type this cmd “firebase init”, it will prompt a few questions like below and answer it in order to create the firebase project at locally

Answer it as “Y” for yes to proceed further and it asks few questions to choose the google cloud features. In this article, we are looking for google function so am selecting “Google function” to create.

5. Select the project to deploy and execute our function and am going to select the existing project.

6. Select the existing project from your google account

7. When creating a cloud function, we have to choose languages like Javascript or TypeScript

I have selected here “JavaScript

8. After selecting the language, it asks us another question for ESLint and this is an option only. Better to choose this and it will help us to check the errors in code before deploying it in the cloud.

That’s all, now project folder has set up and ready to create cloud function

Before that, let’s look at some of the files here:-
1. firebase.json — The firebase.json the file is required to deploy assets with the Firebase CLI because it specifies which files and settings from your project directory are deployed to your Firebase project.

2. firebaserc — a file that stores your project aliases. In this file, we can see our selected project

3. .gitignore — in this file we can ignore the files to deploy when git has set up

4. index.js — this is the main file to write functions

5.package.json — this is a very important file that consists of functions name, dependencies, scripts, engines (node.js with version), etc.., This file helps to install the dependency files while deployment.

Sample project folder structure looks like :

Let's see how to create cloud functions in my next article — please click here

Happy Learning!!!