We are keeping your runtime up to date in accordance with industry standards. Based on the Node.js support schedule, Node.js v16 is no longer in Maintenance long-term support (LTS). Production applications should only use releases of Node.js that are Active LTS or Maintenance LTS.
Re-deploy and test your Functions on the Node.js v18 runtime before February 1st, 2024. A deployment will be required to make your Functions run on the new version of Node.js.
After February 1st, 2024, if you make changes to your Functions, they will need to be deployed on Node.js v18.
Currently, the Node.js version will only change if you explicitly set it via either the UI dropdown in the Dependencies tab, by passing runtime
when using the Serverless Toolkit, or by explicitly setting the runtime
parameter when creating a Build.
Your currently deployed Functions will continue to execute on the existing Node.js v16 runtime if no changes are made.
We encourage all customers to upgrade to Node.js v18, even if you are not planning on making any other changes to your Functions.
Follow the instructions below to upgrade, test, and deploy your code on Node.js v18 before the February 1st, 2024 deadline.
While there are no syntax changes required for the upgrade from Node.js v16 to v18, a possible area of impact is your Service's NPM dependencies. It is important to check that the dependencies you include are supported on Node.js v18.
If you have built your application with the latest Functions Editor, you can update your Node.js runtime by following these steps:
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 node18
.
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 node18
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.
Some Serverless Toolkit components depend on 3rd party libraries. These dependencies can be updated by their creators to support Node.js v18 without prior notice. We encourage all customers to upgrade to Node.js v18, even if you are not planning on making any other changes to your Functions.
To avoid unexpected side effects when trying out Node.js v18 make sure to follow these exact steps. Learn more about the possible side effects.
You should be using @twilio-labs/plugin-serverless
version 3.1.0
or newer. You can run twilio plugins
to verify your version.
If your version of the Serverless Toolkit does not meet these requirements, you may upgrade to the latest version using the following commands:
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": "node18"3}
This will ensure that if you don't declare a specific Node.js runtime it will always use Node.js v16 to ensure that you are not accidentally switching to Node.js v18 before verifying it.
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 v18 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 node18 --environment verify-18
Your Functions will now be deployed and running on the Node.js v18 runtime in that environment.
Once you have verified your code with Node.js v18, you can update the .twilioserverlessrc
file to use node18
as the runtime.
1{2"runtime": "node18"3}
That means any future deployments will use Node.js v18 even if you don't pass in the specific runtime using the --runtime
flag.
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.
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.
If you would like to change the Node.js runtime within Functions(Classic), please reach out to 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 v18 once, any subsequent deployments that don't specify a specific runtime will automatically use Node.js v18 going forward.
To avoid these side effects:
.twilioserverlessrc
file.