Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Dependencies


Runtime features an integrated package manager that handles the retrieval, installation, and deployment of third-party packages to support your Functions. This enables developers to access an incredible collection of packages provided by the Node.js community via npm(link takes you to an external page).


Default Dependencies

default-dependencies page anchor

The default version of the Twilio SDK and Runtime handler are a part of all Builds.

You will always see twilio and @twilio/runtime-handler in the Dependencies pane of the Twilio Console UI, package.json if using the Serverless Toolkit, and in the Build response returned by the Serverless API.

(information)

Info

@twilio/runtime-handler is not utilized by Functions (Classic), and is not a default dependency in that context.


(warning)

Warning

Only public packages, like those hosted by npm, can be managed by the methods below. If you require a private package, you should add it as a private Asset and access it from your Function's code instead.

Twilio ConsoleServerless ToolkitFunctions (Classic)

Developers can add, remove and update Dependencies through the Console(link takes you to an external page).

Click the Dependencies option under Settings to see your Dependencies in the Functions Editor.

Runtime Dependencies UI.

_11
// package.json
_11
{
_11
// Other values omitted...
_11
"dependencies": {
_11
"twilio": "^3.56",
_11
"@twilio/runtime-handler": "1.2.1"
_11
},
_11
"devDependencies": {
_11
"twilio-run": "^3.4.0"
_11
}
_11
}


  1. Use your package manager of choice to install any new dependencies or development dependencies. Using npm, an example command would be:


    _10
    npm install axios

  2. Deploy your project to ensure that the dependency is available for the deployed Function. For example:


    _10
    twilio serverless:deploy


Changing the version of a Dependency

changing-the-version-of-a-dependency-2 page anchor
  1. Update the version of the intended dependency

    • Use your package manager of choice to update your intended dependency. For example:


      _10
      npm update axios

    • Manually change the dependency's version range(link takes you to an external page) in package.json , then run the equivalent of npm install to install the newly specified version.
  2. Deploy your project to ensure that the dependency is available for the deployed Function. For example:


    _10
    twilio serverless:deploy


  1. Use your package manager of choice to remove the desired dependency. For example:


    _10
    npm uninstall axios

  2. Deploy your project to ensure that the dependency is removed from all subsequent deployments. For example:


    _10
    twilio serverless:deploy

For additional details, check out the Project Dependencies section of the Serverless Toolkit docs.


Keeping Twilio helper libraries up to date enables you to take advantage of the latest Twilio product functionality.

You can determine the latest(link takes you to an external page) version of the Twilio Node helper library, or set the latest Dependencies(link takes you to an external page) for your Twilio functions by setting them to * or latest in the Twilio Console UI.

If using the Serverless Toolkit and package.json, you could alternatively use a dependency version range(link takes you to an external page) such as "latest".

(warning)

Warning

The version of @twilio/runtime-handler must be defined as an explicit value, such as 1.2.1. Using version ranges, such as * and latest, will result in a Build failure.


  • Native packages are not supported — Runtime does not provide a C/C++ compiler, which is required to compile native add-on modules. This means modules that depend on node-gyp(link takes you to an external page) can not be used in your Functions.
  • npm modules limit — Services are limited in the number of npm modules that may be installed. This is dependent on which version of Runtime you are using:

    • Current version: 100 modules.
    • Functions (Classic): 20 modules.
    • To raise these limits for one of your Services, please contact Twilio Support.

Rate this page: