【问题标题】:Firestore function deployment error when using Twilio使用 Twilio 时 Firestore 功能部署错误
【发布时间】:2020-07-18 16:08:43
【问题描述】:

我正在尝试将 Twilio 集成到触发的 Firestore 功能中。我遇到的问题是当我添加此代码时,我无法部署任何功能。据我所知,这是如何在云功能中使用 twilio。在顶部我有这个,我认为 firebase 不喜欢这里的东西,因为所有函数都停止使用此代码部署。

// Used to send text messages
const twilio = require('twilio')
// const accountSid = functions.config().twilio.sid
// const authToken  = functions.config().twilio.token

/* eslint new-cap: ["error", { "newIsCap": false }] */
const client = new twilio('ACblahblahblah', 'ccblahblahblah') // sid and token
const twilioNumber = '+13344714571' // your twilio phone number

在触发函数中我有这个。但我认为问题不在这里:

       return client.messages.create({
          to: someNumber,
          from: twilioNumber,
          body: 'Some message.'
        }).then((data) => {
          console.log(data)
        }).catch((error) => {
          console.log(error)
        })

我设置了一个有效的 Twilio 帐户。除了函数无法初始化之外,函数日志并没有告诉我太多。我错过了什么?似乎这对其他人有用。

【问题讨论】:

  • 请编辑问题以解释“所有功能停止使用此代码部署”的意思。你在观察什么?要具体,并显示任何错误消息。我们应该能够使用您在问题中提供的内容重现该问题。

标签: javascript node.js firebase google-cloud-firestore twilio


【解决方案1】:

在发布问题大约 5 分钟后想通了。我没有在函数文件夹中安装 twilio,而是在项目的根目录中安装。一旦我执行了

npm install twilio 

在函数文件夹中,函数开始部署。太糟糕了,日志中没有显示“缺少所需的包”之类的错误。

【讨论】:

    猜你喜欢
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    • 2020-10-15
    • 2021-12-01
    • 2018-08-20
    • 1970-01-01
    相关资源
    最近更新 更多