I have a Twilio serverless app that contains several functions. Several of the functions have code that is similar that I have extracted out into a separate file that can be used by the loaded and used by the functions.
This works if I run things locally with twilio serverless:start
, but fails when I deploy to Twilio and try using the endpoints from their. On Twilio the functions fail with the message Cannot find module '<path to module>' \nRequire stack ...
functions (two files like this):
const share = require('shared-code');
shared-code.js
:
exports.helperFn = function() {}
How can I easily share JavaScript code between Twilio functions?