我已经创建了一个.env文件(它应该有一个名称,还是只需要扩展名?)我在信中写了我的证件:
TWILIO_ACCOUNT_SID=AC---------------------------
TWILIO_API_KEY=SK------------------------------
TWILIO_API_SECRET=-------------我已经安装了来自npm的dotenv包,这段代码工作得很好:
const dotenv = require('dotenv');
const result = dotenv.config()
if (result.error) {
throw result.error
}
console.log(result.parsed)但是,当我尝试运行cli命令时: twilio电话号码:update "+xxxxxxxxxx“--sms-url="http://localhost:1337/sms”
它告诉我:
Alternatively, twilio-cli can use credentials stored in environment variables:
# OPTION 1 (recommended)
TWILIO_ACCOUNT_SID = your Account SID from twil.io/console
TWILIO_API_KEY = an API Key created at twil.io/get-api-key
TWILIO_API_SECRET = the secret for the API Key尝试按照教程中的建议使用cli来更新我的号码的web钩子并自动运行ngrok。如果在脚本中可以通过dotenv明确地访问这些值,那么cli为什么看不到.env中的值呢?
发布于 2020-03-13 08:29:29
.env文件不是创建环境变量的标准文件。在您的脚本中,您使用了dotenv包,它读取这个特定的文件并为您设置环境变量。
对于twilio cli,必须显式地设置这些环境变量。有多种方法可以做到这一点。
导出twilio _ --sms-url="http://localhost:1337/sms"
.bashrc,以便它们总是可用的
.env文件如下导出$(cat )& twilio电话号码:--sms-url="http://localhost:1337/sms"更新"+xxxxxxxxxx“
https://stackoverflow.com/questions/60667006
复制相似问题