我发现了一个错误。Typescript编译目录
我在index.ts中有打字脚本代码
import * as functions from "firebase-functions";
import * as cors from "cors";
cors({ origin: true });
exports.myFunc = functions.https.onCall((data, context) => {
const { uid } = context.auth;
return { uid };
});
如果我尝试部署此功能:
firebase deploy --only functions:myFunc
我回来了:
函数:指定了以下筛选器,但与任何筛选器都不匹配项目中的功能:myFunc
我做错了什么?
lib/functions/src/index.js
中的.js文件,但我的package.json文件有主文件的外部路径
{
...
"main": "lib/index.js",
...
}
我换了
{
...
"main": "lib/functions/src/index.js",
...
}
它成功了!
// index.js
const functions = require('firebase-functions');
const cors = require('cors');
cors({ origin: true });
exports.myFunc = functions.https.onCall((data, context) => {
const { uid } = context.auth;
return { uid };
});
则$ firebase deploy --only functions