Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Upgrading Node.js for Twilio Functions


Twilio Functions supports multiple Node.js runtimes. Node.js v24 is the current Active LTS runtime and the recommended choice for new and existing Services. Node.js v22 remains supported in Maintenance LTS.

RuntimeStatusNotes
Node.js v24Active LTSCurrent recommended runtime (v2 Services)
Node.js v22Maintenance LTSSupported; upgrade to v24 recommended
Node.js v20End of lifeNot supported
(information)

Info

Node.js v24 is available for v2 Services only. If you are using Functions(Classic) (v1), see Upgrading to Node.js v22.

To set the Node.js version for a Service, do one of the following:

  • Use the Node Version dropdown in the Dependencies tab.
  • Set the runtime parameter when creating a Build.
  • Pass the runtime when using the Serverless Toolkit.

Your deployed Functions continue to execute on their existing runtime if no changes are made.


Upgrading to Node.js v24

upgrading-to-nodejs-v24 page anchor
(warning)

Warning

Node.js v24 requires @twilio/runtime-handler version 2.1.2 or higher. If your Service specifies version 1.2.0 or later, the platform upgrades it automatically at build time. If your Service specifies a version earlier than 1.2.0, the build fails — update @twilio/runtime-handler to at least 2.1.2 before targeting node24. See Runtime Handler for details.

(error)

Danger

While there are no syntax changes required for the upgrade to Node.js v24, check that your npm dependencies support Node.js v24 before deploying.

Using the Functions Editor UI

using-the-functions-editor-ui page anchor

If you have built your application with the latest Functions Editor(link takes you to an external page), you can update your Node.js runtime by following these steps:

  1. Open the Dependencies tab of an existing Service that you wish to update.
  2. Open the Node Version dropdown menu, and select Node.js v24.
  3. Click the Deploy All button to build and deploy your Service. Once complete, all Functions within that Service will be running on Node.js v24.

Using the Serverless API

using-the-serverless-api page anchor

If you are using the Serverless API to build and deploy your Services, you can update your Node.js runtime by creating a new Build of your Service with the runtime parameter set to node24.

Using the Twilio CLI and your own Service SID, the command will be:

1
twilio api:serverless:v1:services:builds:create \
2
--service-sid ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
3
--runtime node24

If you'd prefer to use an SDK to trigger this build, refer to the Build documentation for examples of how to trigger a build in every supported programming language.

Using the Serverless Toolkit

using-the-serverless-toolkit page anchor
(warning)

Warning

Some Serverless Toolkit components depend on 3rd party libraries. These dependencies can be updated by their creators to support Node.js v24 without prior notice. We encourage all customers to upgrade to Node.js v24, even if you are not planning on making any other changes to your Functions.

(warning)

Warning

To avoid unexpected side effects when trying out Node.js v24 make sure to follow these exact steps. Learn more about the possible side effects.

Validate you are on the latest Serverless Toolkit version

validate-you-are-on-the-latest-serverless-toolkit-version page anchor

Run twilio plugins to check your current version. To upgrade to the latest:

1
twilio plugins:remove @twilio-labs/plugin-serverless
2
twilio plugins:install @twilio-labs/plugin-serverless@latest

Define your baseline Node.js version

define-your-baseline-nodejs-version page anchor

Open the .twilioserverlessrc configuration file at the root of your project and make sure it includes:

1
{
2
"runtime": "node24"
3
}

If you are working with multiple people or deploying as part of your CI/CD system, make sure that everyone in your team has the updated .twilioserverlessrc file, for example by pushing it to your version control system.

Create your first deployment with Node.js v24

create-your-first-deployment-with-nodejs-v24 page anchor

To trigger a new deployment with Node.js v24 you can use the --runtime flag. Ideally deploy to a new environment, so you can verify the functionality in isolation.

The deployment command will be:

twilio serverless:deploy --runtime node24 --environment verify-24

Your Functions will now be deployed and running on the Node.js v24 runtime in that environment.

Finalize your Node.js v24 transition

finalize-your-nodejs-v24-transition page anchor

Once you have verified your code with Node.js v24, you can update the .twilioserverlessrc file to use node24 as the runtime.

1
{
2
"runtime": "node24"
3
}

That means any future deployments will use Node.js v24 even if you don't pass in the specific runtime using the --runtime flag.


Upgrading to Node.js v22

upgrading-to-nodejs-v22 page anchor

If you are still on Node.js v20 or v18, upgrade to Node.js v22 using the steps below.

(error)

Danger

While there are no syntax changes required for the upgrade from Node.js v20 to v22, check that your npm dependencies support Node.js v22 before deploying.

Using the Functions Editor UI

using-the-functions-editor-ui-1 page anchor

If you have built your application with the latest Functions Editor(link takes you to an external page), you can update your Node.js runtime by following these steps:

  1. Open the Dependencies tab of an existing Service that you wish to update.
  2. Open the Node Version dropdown menu, and select Node.js v22.
  3. Click the Deploy All button to build and deploy your Service. Once complete, all Functions within that Service will be running on Node.js v22.

If you are using the Serverless API to build and deploy your Services, you can update your Node.js runtime by creating a new Build of your Service with the runtime parameter set to node22.

Using the Twilio CLI and your own Service SID, the command will be:

1
twilio api:serverless:v1:services:builds:create \
2
--service-sid ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
3
--runtime node22

If you'd prefer to use an SDK to trigger this build, refer to the Build documentation for examples of how to trigger a build in every supported programming language.

Using the Serverless Toolkit

using-the-serverless-toolkit-1 page anchor

Run twilio plugins to check your current version. To upgrade to the latest:

1
twilio plugins:remove @twilio-labs/plugin-serverless
2
twilio plugins:install @twilio-labs/plugin-serverless@latest

Open the .twilioserverlessrc configuration file at the root of your project and set:

1
{
2
"runtime": "node22"
3
}

Deploy to a test environment first:

twilio serverless:deploy --runtime node22 --environment verify-22

Once verified, future deployments will use node22 automatically.


How do I verify that the upgrade was successful?

how-do-i-verify-that-the-upgrade-was-successful page anchor

Your runtime version of Node.js is exposed on the process.version variable, so creating, deploying, and calling a short Function like this will return the current version for verification purposes:

1
exports.handler = (context, event, callback) => {
2
return callback(null, process.version);
3
};

What if I'm still using Functions(Classic)?

what-if-im-still-using-functionsclassic page anchor

The simplest way to upgrade is to start by using the new Functions editor.

  1. Create a new Service in the New Functions editor(link takes you to an external page).
  2. Copy your Functions code into the new Service as new Functions.
  3. Copy over any Environment Variables and/or Dependencies that your Function(s) use.
  4. Deploy your new Functions by clicking Deploy All. Your code will be deployed using Node.js v24 by default.
  5. If you wish to test with Node.js v24, you can do so by navigating to the Dependencies tab, selecting Node.js v24 from the Node Version dropdown, and clicking Deploy All for the change to take effect.
  6. Test that your Functions work as expected in the new Service. Once confident, you can switch your Functions to use Node.js v24.

Be sure to update any references to your old Function (e.g. Studio Flows, Twilio number config) to use the new Function URL. You can copy your new Function URL by clicking Copy URL at the bottom right of the Function editor.

(information)

Info

If you would like to change the Node.js runtime within Functions(Classic)(link takes you to an external page), contact Twilio Support(link takes you to an external page) with your Account SID and request that they change the Node.js runtime for you.


If you are using the API directly or the Serverless Toolkit, you might encounter possible side effects if you don't explicitly specify a runtime with each deployment.

By default, if you are not specifying a runtime when creating a Build the API will use the runtime you used for the last successful Build. That means if you successfully deployed your code with Node.js v24 once, any subsequent deployments that don't specify a specific runtime will automatically use Node.js v24 going forward.

To avoid these side effects:

  • With the API: Always pass a runtime parameter when creating a Build
  • With the Serverless Toolkit: Make sure to follow the steps outlined above, especially defining a default runtime in the .twilioserverlessrc file.