How do I switch apps from the firebase cli?

Solution 1:

Found some useful information here Firebase CLI Reference.

The following code works for me.

firebase use <project_id>

Solution 2:

I rather use scripts. Consider a project structure like this:

your-project
├── .firebaserc
└── functions
   ├── package.json
   └── index.js

Go to .firebaserc and follow the next example

{
  "projects": {
    "default": "project-name",
    "prod": "other-name"
  }
}

Then go to package.json and add the following scripts (changeToProd, and changeToDev).

{
  ...
  "scripts": {
    ...
    "changeToProd": "firebase use prod",
    "changeToDev": "firebase use default"
  },
  "dependencies": {
    ...
  },
  ...
}

If your IDE support npm scripts you can run them using the IDE UI, otherwise it can be run using the command console. Make sure you are inside the functions folder.

npm run-script changeToProd

You can verify your current project by running the following command from the terminal or added to the scripts as we just did

firebase use

Solution 3:

If you are using Node.js on windows, your answer should be

firebase use <project_id>

but without the <> for example

firebase use chat-app-2a150

You can use the following code to view all your projects so as to pick the correct project ID to use

firebase projects:list