Đây là tiêu đề của file Node.js index.js:admin.firestore không phải là một chức năng khi cố gắng sử dụng các chức năng điện toán đám mây google với Node.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
var db = admin.firestore();
Đây là Node.js chức năng để lắng nghe những thay đổi FireStore:
exports.myFoo = functions.firestore
.document('foo/{bar}')
.onWrite(event => {
// do stuff
}
này nằm trong tập tin package.json:
"dependencies": {
"firebase-admin": "^5-.4.2",
"firebase-functions": "^0.7.1",
"firestore": "^1.1.6"
},
Khi tôi cố gắng để làm một "triển khai căn cứ hỏa lực" lệnh này là lỗi Tôi nhận:
Error: Error occurred while parsing your function triggers.
TypeError: admin.firestore is not a function
Có lẽ bạn không có phiên bản SDK mới nhất. Làm như được mô tả trong [tài liệu] (https://firebase.google.com/docs/functions/get-started#set_up_and_initialize_functions_sdk) bằng cách chạy 'npm install firebase-functions @ latest --save' trong thư mục hàm của dự án của bạn. –
Tôi không nghĩ rằng bạn cần linh hoạt trong các phụ thuộc? Tôi có đoạn mã fireestore/firebase-functions hoạt động, chỉ có hai phụ thuộc 'firebase-admin": "^ 5.4.1" 'và' "firebase-functions": "^ 0.7.0" ' – DauleDK
@BobSnyder Tôi chạy cả hai 'npm cài đặt firebase-functions @ mới nhất --save' và' npm install -g firebase-tools' rồi thử triển khai lại 'firebase' nhưng thông báo lỗi tương tự vẫn xuất hiện. Tôi có phiên bản firebase 3.13.1 và phiên bản npm 3.10.10. –