即使没有将函数从 onCallable 更改为 onRequest,Firebase 部署也会失败

Firebase deploy failed even without changing the function from onCallable to onRequest

Error: [functionName(us-central1)] Changing from a callable function to an HTTPS function is not allowed. Please delete your function and create a new one instead.

欢迎任何建议和见解。

解决方案 01:
我认为主要问题在于您是否使用有效的方式来使用 .env 文件。因为我最近有这种错误。如果您在文件夹结构中使用 .env 文件,那么

  • 您需要在所有使用 process.env.VARIABLE_NAME 的文件中声明 .env 文件的路径。示例方法是这样的: require("dotenv").config({path: "../.env"});
  • 之后尝试删除 Google Cloud Console
  • 中所有现有的 Cloud Functions
  • 再次尝试部署:firebase deploy --only functions

我添加了 .env 文件的路径,因为我检查了 Firebase Cloud Function Logs,它给了我所有使用 process.env.VARIABLE_NAME 的 Cloud Functions 的错误。此 .env 文件必须位于根项目内并放置在文件夹 functions/ 内。试试看。希望有用。

解决方案编号。 2:
您应该检查是否存在不提供 return 值的变量或函数,如下例所示:

const key = async () => {
  const response = await pk.accessSecret("PRIVATEKEY");
  return response;
};


我忘记从变量 const 键中添加一个 return 值。因此,在我的所有功能中,我都会像您一样遇到很多错误。那个错误导致 firebase cli 声明“

Changing from a callable function to an HTTPS function is not allowed. Please delete your function and create a new one instead.

您使用的是哪个版本的 Firebase CLI (firebase --version)?昨晚我将 firebase-tools 包更新到 10.3.0,功能部署开始给我你提到的错误。我降级到 10.2.2,功能部署开始像以前一样工作。

更新: Firebase 团队确认 10.3.0 firebase-tools 存在问题。他们正在努力修复: https://github.com/firebase/firebase-tools/issues/4307

这也发生在我身上。 npm i -g firebase-tools@latest 成功了。