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.
| Runtime | Status | Notes |
|---|---|---|
| Node.js v24 | Active LTS | Current recommended runtime (v2 Services) |
| Node.js v22 | Maintenance LTS | Supported; upgrade to v24 recommended |
| Node.js v20 | End of life | Not supported |
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
runtimeparameter when creating a Build. - Pass the
runtimewhen using the Serverless Toolkit.
Your deployed Functions continue to execute on their existing runtime if no changes are made.
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.
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.
If you have built your application with the latest Functions Editor, you can update your Node.js runtime by following these steps:
- Open the Dependencies tab of an existing Service that you wish to update.
- Open the Node Version dropdown menu, and select Node.js v24.
- 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.
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:
1twilio 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.
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
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.
Run twilio plugins to check your current version. To upgrade to the latest:
1twilio plugins:remove @twilio-labs/plugin-serverless2twilio plugins:install @twilio-labs/plugin-serverless@latest
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.
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.
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.
If you are still on Node.js v20 or v18, upgrade to Node.js v22 using the steps below.
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.
If you have built your application with the latest Functions Editor, you can update your Node.js runtime by following these steps:
- Open the Dependencies tab of an existing Service that you wish to update.
- Open the Node Version dropdown menu, and select Node.js v22.
- 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:
1twilio 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.
Run twilio plugins to check your current version. To upgrade to the latest:
1twilio plugins:remove @twilio-labs/plugin-serverless2twilio 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.
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:
1exports.handler = (context, event, callback) => {2return callback(null, process.version);3};
The simplest way to upgrade is to start by using the new Functions editor.
- Create a new Service in the New Functions editor.
- Copy your Functions code into the new Service as new Functions.
- Copy over any Environment Variables and/or Dependencies that your Function(s) use.
- Deploy your new Functions by clicking Deploy All. Your code will be deployed using Node.js v24 by default.
- 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.
- 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.
Info
If you would like to change the Node.js runtime within Functions(Classic), contact Twilio Support 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
.twilioserverlessrcfile.