最近,我尝试在线跟踪一些演示,开始使用Google Firebase Cloud Functions Node.js服务器端代码.在尝试添加Firebase应用程序(以及带有它的Firestore)时,
const functions = require('firebase-functions');
const firebase = require('firebase-admin');
require('firebase/firestore');
var serviceAccount = require("<private key>.json");
const initAppFirebase = firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: "<URL>"
});
var db = firebase.firestore();
Run Code Online (Sandbox Code Playgroud)
我开始得到这一个错误,它提到了google-gax模块中丢失的"annotations.proto"文件(显然是在Firestore中的某个点导入的).
Error during trigger parsing: Error occurred while parsing your function
triggers.
Error: The include `google\api\annotations.proto` was not found.
at Function.GoogleProtoFilesRoot._findIncludePath
(C:\...\functions\node_modules\google-gax\lib\grpc.js:312:11)
at GoogleProtoFilesRoot.resolvePath
(C:\...\functions\node_modules\google-gax\lib\grpc.js:298:31)
...
at v1beta1 (C:\...\functions\node_modules\@google-
cloud\firestore\src\v1beta1\index.js:30:10)
at new Firestore (C:\...\functions\node_modules\@google-
cloud\firestore\src\index.js:229:18)
Run Code Online (Sandbox Code Playgroud)
我在互联网上环顾四周,但似乎没有其他人有这个问题.我刚刚重新安装了这些文件,但我仍然遇到了这个问题.删除Firestore和Firebase initializeApp代码可以使其正常工作,因此我认为它与此有关.
这是我的模块版本 package.json
"firebase-admin": "^5.12.0",
"firebase-functions": "^1.0.1",
"firestore": "^1.1.6",
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题(拙劣的安装,过时的库,缺少代码/要求等)?非常感谢你.
编辑 …
node.js firebase google-cloud-functions google-cloud-firestore