Я знаю, что кто-то еще разместил этот вопрос до , но я считаю, что у меня есть правильное объявление и все еще не работает:
Запуск sendEmail.js:
node sendEmail.js
Внутри sendEmail.js:
"use strict";
// Initialize Function Caller App
const firebase = require("firebase");
// Required for side-effects
require("firebase/functions");
var config = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "my-project-id.firebaseapp.com",
databaseURL: "https://my-project-id.firebaseio.com",
projectId: "my-project-id",
storageBucket: "my-project-id.appspot.com",
messagingSenderId: "xxxxxxxxxx"
};
firebase.initializeApp(config);
var functions = firebase.functions(); // Error here: TypeError: firebase.functions is not a function
Я получил приведенный выше пример из Документации Firebase . Это работает для моего другого проекта, но не текущего. Я также запустил в своей папке sendEmail.js
следующее:
npm install firebase@5.10.1 --save
В моей корневой папке проекта Firebase мой файл package.json
также имеет зависимость firebase-functions
:
"dependencies": {
"firebase": "^5.10.0",
"firebase-admin": "^7.3.0",
"firebase-functions": "^2.3.0",
"nodemailer": "^6.1.0"
},
Но, к вашему сведению, мой sendEmail.js
находится в следующей папке:
project-root\testing\sendEmail.js
project-root\testing\node_modules\@firebase
project-root\testing\node_modules\@firebase\functions
И я все еще получаю эту ошибку:
var functions = firebase.functions();
^
TypeError: firebase.functions is not a function
at Object.<anonymous> (d:\project-root\testing\sendEmail.js:17:26)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
Могу ли я узнать, что еще мне нужно проверить? Любая помощь будет высоко ценится, спасибо!