[英]AWS Lambda function not accepting Twilio Module
Whenever I try to include Twilio
module in my Lambda Function, it gives out an error: 每当我尝试在我的Lambda函数中包括
Twilio
模块时,它都会发出错误:
"errorMessage": "Cannot find module 'twilio'"
“ errorMessage”:“找不到模块'twilio'”
The error is on line: 错误在线:
var client = require('twilio')(accountSid, authToken);
Can anyone help me out with the way we can include modules? 有人可以帮我介绍模块的方法吗?
Twilio developer evangelist here. Twilio开发人员布道者在这里。
There's a really good tutorial on how to include npm modules in Lambda written by the AWS team. 由AWS团队撰写的关于如何在Lambda中包含npm模块的教程非常不错。 It shows how to use Node.js packages in Lambda .
它显示了如何在Lambda中使用Node.js包 。
The short version is that you should build your Lambda function locally as you would any other Node.js script, installing the modules as you go into the script. 简短的版本是,您应该像其他任何Node.js脚本一样在本地构建Lambda函数,并在进入脚本时安装模块。 Then, once it is working, zip up your entire directory, including the
node_modules
directory inside, and use Lambda's createFunction API, CLI, or the console UI to deploy it. 然后,一旦运行,请压缩整个目录,包括内部的
node_modules
目录,并使用Lambda的createFunction API,CLI或控制台UI进行部署。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.