Failed to parse service account key file

4,367 views
Skip to first unread message

Hima Tammineedi

unread,
Jul 22, 2016, 12:43:39 AM7/22/16
to Firebase Google Group
I'm using the Firebase npm module, and for some reason I can't start my server anymore even though I used to be able to a few weeks ago.
When I type "npm start" I get 
project\node_modules\firebase\auth-node\auth.js:29
      throw new Error('Failed to parse service account key file: ' + error);
      ^

Error: Failed to parse service account key file: Error: ENOENT: no such file or directory, open 'project\eebooks\eebooks-065dd2a531ca-credentials.json'
    at getServiceAccount (project\node_modules\firebase\auth-node\auth.js:29:13)
    at new Auth (project\node_modules\firebase\auth-node\auth.js:77:25)
    at Object.serviceFactory [as auth] (project\node_modules\firebase\auth-node\index.js:17:14)
    at N.u (project\node_modules\firebase\app-node.js:13:94)
    at project\node_modules\firebase\auth-node\index.js:34:9
    at project\node_modules\firebase\app-node.js:14:322
    at Array.forEach (native)
    at Object.R.e.initializeApp (project\eebooks\node_modules\firebase\app-node.js:14:295)
    at Object.<anonymous> (project\eebooks\routes\index.js:9:28)
    at Module._compile (module.js:409:26)

Where should I be authenticating? I'm not sure where to get this account key file.

Jacob Wenger

unread,
Jul 22, 2016, 3:07:47 PM7/22/16
to fireba...@googlegroups.com
Hey Hima,

This error is being thrown because you are referencing a file path that doesn't exist. It may be because by default in Node.js, the path will be relative to where the Node.js process is run, not where the file including the path is located. You might need to use Node's built-in path module to make sure the code works when run from any directory. Your would do something like this:

var path = require("path");

// ...

firebase.initializeApp({
  serviceAccount: path.resolve(__dirname, './project/eebooks/eebooks-065dd2a531ca-credentials.json')
});

The second argument to path.resolve() should be relative to the file location of the code calling path.resolve(). I took a guess at what that path is given the error message you logged, but you might need to edit it depending on how your files are organized.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/0d5f298b-9305-4765-ba7b-61e0e22e3b0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages