为什么 Firebase 函数 onCall 没有部署?

Dar*_*Sir 1 javascript firebase typescript google-cloud-functions

我在 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 };
});
Run Code Online (Sandbox Code Playgroud)

如果我尝试部署此功能:

firebase deploy --only functions:myFunc
Run Code Online (Sandbox Code Playgroud)

我回来了:

函数:指定了以下过滤器但不匹配项目中的任何函数:myFunc

我究竟做错了什么 ?

Dar*_*Sir 5

我发现了一个错误。打字稿在目录中编译我的 .js 文件,lib/functions/src/index.js但我的 package.json 文件有主文件的外部路径

{
  ...
  "main": "lib/index.js",
  ...
}
Run Code Online (Sandbox Code Playgroud)

我改为

{
  ...
  "main": "lib/functions/src/index.js",
  ...
}
Run Code Online (Sandbox Code Playgroud)

它奏效了!