First time deploying a GAE app here, I\'m trying to follow this tutorial: https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html (see node code secti
These issues seem to be caused by a misunderstanding of how require()
paths work. You cannot use an absolute path because something like require("/Users/username/somepath")
obviously won't exist on the remote machine when the app is deployed and the import will fail. Using require("serviceAccountKey.json")
is going to look in node_modules/serviceAccountKey.json relative to the app directory.
If you want to load serviceAccountKey.json from the app's root directory, you would use require("./serviceAccountKey.json")
. If it were in a subdirectory called foo under the root you'd use require("./foo/serviceAccountKey.json")
. This also applies to loading modules in general such as firebase-admin
.
The NodeJS Modules documentation explains the require()
mechanism in greater detail.