首页 > 解决方案 > Firebase 函数的目标部署

问题描述

我正在尝试为 Firebase Functions 设置目标部署。 https://firebase.google.com/docs/cli/targets

这是 firebase.json 文件

{
  "functions": [{
    "target": "production",
    "source": "src/prod/functions",
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  }]
}

预部署运行正常,但部署时出错

functions[prod]: Finished running predeploy script.
Error: An unexpected error has occurred.

如果我去 firebase-debug.log 它显示:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

将 Functions 文件夹放在项目根目录上,它将正常部署。

这里缺少什么?

标签: firebasegoogle-cloud-functionsfirebase-cli

解决方案


尝试运行firebase init并尽可能设置选项,这样它就不会覆盖您现有的项目。我必须从父目录运行它,/functions否则它将创建一个新目录,但也许有一些选项可以设置不同的目录名称以适合您的情况。


推荐阅读