When trying to run a basic node file with Firebase and Firestore, the following code was used:
const firebase = require("firebase");
const http = require('http')
require("firebase/firestore");
firebase.initializeApp({
apiKey: '...',
authDomain: '...',
databaseURL: '...',
serviceAccount: '...',
projectId: '...'
});
var db = firebase.firestore();
var userRef = db.collection('...').doc('...');
However, upon running this code, an unexpected error occurred in the terminal:
Firestore (4.5.2) 2017-10-18T19:16:47.719Z: INTERNAL UNHANDLED ERROR: Error: Failed to fetch file at /.../project/node_modules/protobufjs/dist/protobuf.js:5164:30 at ReadFileContext.callback (/.../p/node_modules/protobufjs/dist/protobuf.js:358:29) at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13) (node:43981) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to fetch file (node:43981) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The necessary protobuf.js file was present in the node_modules folder and reinstalling it did not resolve the issue. It seems that the problem is specific to this setup and version of protobuf.js.