twiliotwilio-functions

Cannot find module "@sendgrid/mail"


I'm using the Sendgrid mail package (https://www.npmjs.com/package/@sendgrid/mail) to send a test email using the Twilio Serveless functions. I have configured the module, specifying the correct version and module in the configure dashboard here. https://www.twilio.com/console/functions/configure but when I deploy my function and run it using the twilio cli, i get the error message,

"message":"Cannot find module '@sendgrid/mail'"

I find this weird since deploying the function manually under the Manage tab, https://www.twilio.com/console/functions/manage tab works like a gem. I'm I missing something?

Or does the serverless API doesn't currently support this? (the same package configurations work when I manually deploying the function)


Solution

  • the Twilio GUI Console based Functions are separate and distinct from the API based functions. You can find more detail here.

    Beta limitations, known issues and limits

    You can add the npm module(s) using npm install , as detailed here.

    Twilio Serverless Toolkit - Deploy a Project

    "Any dependency that is listed in the dependencies field in your package.json will automatically be installed in your deployment."

    If you use the Visual Studio Code approach, you can do the same.