Sunday 2 April 2017

Firebase Admin Nodejs cannot find module service_account.json

I start my node with "node firebasedb.js". My firebasedb.js contains this code:

var admin = require("firebase-admin");

var serviceAccount = require("service_account.json");

// Initialize Firebase
var config = {
    credential: admin.credential.cert(serviceAccount),
    apiKey: "<api key>",
    authDomain: "<auth domain>",
    databaseURL: "<database url>",
    storageBucket: "<storage bucket>",
};

admin.initializeApp(config);

When I run node, I am in the directory where the .json file exists. But it says

Error: Cannot find module 'service_account.json'



via Zik

No comments:

Post a Comment