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:
Mainly followed this guide: https://www.twilio.com/blog/twilio-functions-typescript
Deployed the repo via:
twilio serverless:deploy --functions-folder build/src/functions --runtime node14 --override-existing-project
Before compiling to javascript my import statement looks like this:
import '@twilio-labs/serverless-runtime-types';
import * as VoiceResponse from '@twilio-labs/serverless-runtime-
types/node_modules/twilio/lib/twiml/VoiceResponse';
import { Context, ServerlessCallback, ServerlessFunctionSignature, TwilioClient } from
'@twilio-labs/serverless-runtime-types/types';
And after compiling the import statement looks like this:
require("@twilio-labs/serverless-runtime-types");
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.