Syed Asad Abbas Zaidi
Syed Asad Abbas Zaidi

Reputation: 1066

AWS Lambda function not accepting Twilio Module

Whenever I try to include Twilio module in my Lambda Function, it gives out an error:

"errorMessage": "Cannot find module 'twilio'"

The error is on line:

var client = require('twilio')(accountSid, authToken);

Can anyone help me out with the way we can include modules?

Upvotes: 2

Views: 1175

Answers (1)

philnash
philnash

Reputation: 73027

Twilio developer evangelist here.

There's a really good tutorial on how to include npm modules in Lambda written by the AWS team. It shows how to use Node.js packages in Lambda.

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. 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.

Upvotes: 5

Related Questions