ebg11
ebg11

Reputation: 1046

Using firebase tools as a node module in firebase function

I am trying to call the export method from the firebase tools node module in a firebase function.

    await firebase_tools.auth.export(tempLocalFile);

But i am receiving the following error

FirebaseError: No currently active project.
To run this command, you need to specify a project. You have two options:
- Run this command with [1m--project <alias_or_project_id>[22m.
- Set an active project by running [1mfirebase use --add[22m, then rerun this command.
To list all the Firebase projects to which you have access, run [1mfirebase projects:list[22m.
To learn about active projects for the CLI, visit https://firebase.google.com/docs/cli#project_aliases

Is there a way to set the active project in the nodejs cloud function?

Edit

I am initialising the object like so

const firebase_tools = require('firebase-tools');

Upvotes: 0

Views: 296

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83103

I'm not exactly replying to your problem, but note that the auth.export command will not work in a Cloud Function.

As explained in the documentation (See the note at the bottom):

when used in a limited environment like Cloud Functions, not all firebase-tools commands will work programatically because they require access to a local filesystem.

This is the case for the auth.export command. An alternative is to use the listUsers() method of the Admin SDK, as explained here.

Upvotes: 1

Related Questions