我在多个文件中设置了firebase函数。出于某种原因,当我部署时,更改并没有像缓存或其他东西一样应用。
我的文件夹结构如下:
功能/
scr/
index.ts
auth.ts
inventory.ts
这是我的索引:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const functions = require("firebase-functions");
const admin = require("firebase-admin");
exports.auth = require("./auth");
exports.inventory = require("./inventory");
admin.initializeApp();
auth.ts:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const auth_functions = require("firebase-functions");
exports.login = auth_functions.https.onRequest(
(request: any, response: any) => {
response.send("login");
}
);
exports.logout = auth_functions.https.onRequest(
(request: any, response: any) => {
response.send("logout");
}
);
库存.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const inventory_functions = require("firebase-functions");
exports.getByLocation = inventory_functions.https.onRequest(
async (request: any, response: any) => {
response.send("inventory");
});
在我运行之后
firebase deploy --only functions
一切都显示成功,但我没有看到模拟器或部署时的变化。我还尝试重命名/删除一个函数,但cli忽略了它,只显示成功。考虑到日志什么都不告诉我,也没有发生错误,这非常令人沮丧。
问题出现在我的package.json中,index.js的路径错误。基本上是构建到一个与我部署的目录不同的目录。只需要更新到
"main": "lib/index.js",