I'm trying to use the firebase admin sdk in a local node.js script file (outside of firebase-functions) in order to preform some auth and firestore operations.
But I get this error:
{"severity":"WARNING","message":"Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail"}
Error: Failed to determine project ID: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal. Error code: ENOTFOUND
Admin SDK initialization:
const admin = await import('firebase-admin');
const serviceKey = require('path/to/serviceKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceKey),
databaseURL: 'https://{project}.firebaseio.com',
});
All the questions I've found on this error are regarding running firebase-functions locally, but I'm not trying to use firebase-functions, I'm only trying to use admin.auth and admin.firestore locally.
Am I missing something here?