typescripttwiliotwilio-functions

Twilio function deployed with TypeScript cannot find module @twilio-labs/serverless-runtime-types


I'm trying to migrate a Twilio functions repo to use TypeScript. I completely rewritten one of the functions via TypeScript and successfully tested it locally. However, after I deployed the function, it started returning 500 with the following error: "message": "Cannot find module '@twilio-labs/serverless-runtime-types'

I'm trying to find out how I can correctly import and use types.

Some context:


Solution

  • I tried adding the type dependency @twilio-labs/serverless-runtime-types as production dependency rather than a dev dependency via npm.

    npm i @twilio-labs/serverless-runtime-types -P
    

    I deployed the function again after this change. Now, I'm not getting the 500 error and the function works as expected.