【问题标题】:How do firebase deploy?firebase 如何部署?
【发布时间】:2021-07-01 18:33:56
【问题描述】:

我的 firebase deploy 有问题,在 VS Code 中执行命令,显示下一条消息, 我试过安装,卸载依赖,没有解决方案。 谢谢 终端:

jonatan@Jona:~/KOA/s2i-backoffice-web$ firebase deploy

=== Deploying to 'proyecto-s2i'...

i  deploying functions, hosting
⚠  functions: package.json indicates an outdated version of firebase-functions.
Please upgrade using npm install --save firebase-functions@latest in your functions directory.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  hosting[proyecto-s2i]: beginning deploy...
i  hosting[proyecto-s2i]: found 263 files in public
✔  hosting[proyecto-s2i]: file upload complete

Error: An unexpected error has occurred.

File firebase-debug.log, this is the message

[debug] [2021-07-01T15:17:30.726Z] TypeError: Canno t read property 'length' of undefined
    at Object.functionMatchesAnyGroup (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/functionsDeployHelper.js:11:23)
    at have.filter (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/deploymentPlanner.js:25:56)
    at Array.filter (<anonymous>)
    at calculateRegionalFunctionChanges (/usr /local/lib/node_modules/firebase-tools/lib/deploy/functions/deploymentPlanner.js:25:17)
    at Object.createDeploymentPlan (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/deploymentPlanner.js:53:50)
    at release (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release.js:24:48)
    at process._tickCallback (internal/process/next_tick.js:68:7)
[error] 
[error] Error: An unexpected error has occurred.

【问题讨论】:

  • 您好,请分享您的代码,以便我们查看问题所在。乍一看说你有一个未定义的对象,你正在尝试访问它的长度属性
  • 您好,属性 length 是安装了 firebase-tools 的依赖项。

标签: firebase deployment firebase-authentication cloud firebase-tools


【解决方案1】:

我在全新安装时遇到了同样的错误。 我看到 firebase init 在 functions/index.js 创建了一个文件 但是,里面唯一定义的函数被注释掉了。 取消注释并导出函数可解决此问题。

看起来你正在上传一堆文件,你需要函数吗? 如果您在初始化期间选择了“函数”,但未定义任何函数,请尝试此操作。

【讨论】:

    【解决方案2】:

    我只是遇到了确切的问题。正如@Sumit 所暗示的,在functions 的代码中添加显式使用后,问题解决了。

    exports.scheduledFunction = functions.pubsub.schedule('every 5 hours').onRun((context) => {
        console.log('This will be run every 5 hours!');
    });
    

    【讨论】:

      猜你喜欢
      • 2018-08-06
      • 1970-01-01
      • 1970-01-01
      • 2017-08-17
      • 2020-11-24
      • 2017-08-08
      • 1970-01-01
      • 2018-02-20
      • 2018-03-24
      相关资源
      最近更新 更多