Runtime Node.js v14 upgrade

What do you need to know?

We are keeping your runtime up to date in accordance with industry standards. Based on the Node.js support schedule, Node.js v12 will no longer be in Maintenance long-term support (LTS) status after April 30, 2022. Production applications should only use releases of Node.js that are Active LTS or Maintenance LTS.

What do you need to do?

Re-deploy and test your Functions on the Node.js v14 runtime before April 30, 2022. A deployment will be required to make your Functions run on the new version of Node.js.

After April 30, 2022, if you make changes to your Functions, they will need to be deployed on Node.js v14.

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.

What happens if I do nothing?

Your currently deployed Functions will continue to execute on the existing Node.js v12 runtime if no changes are made.

  • After April 30, 2022, if you create a new Service or deploy a Service that has not yet been deployed, it will use Node.js v14 by default.
  • If you have an existing build of a Service deployed, it will continue to use the previously set runtime. After April 30, 2022, any new deployments must be made on Node.js v14; you will not be able to create any new deployments using Node.js v12.
  • If a Service contains only Assets, then the default Node.js runtime will be used automatically for builds (regardless of the runtime parameter that is sent as part of the Build request). After April 30, 2022, the default runtime will be Node.js v14.

We encourage all customers to upgrade to Node.js v14, even if you are not planning on making any other changes to your Functions.

How do I upgrade to Node.js v14?

Follow the instructions below to upgrade, test, and deploy your code on Node.js v14 before the April 30, 2022 deadline.

While there are no syntax changes required for the upgrade from Node.js v12 to v14, 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 v14.

Using the Functions Editor UI

If you have built your application with the latest Functions Editor, 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 v14.
  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 v14.

Using the Serverless API

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 node14.

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

twilio api:serverless:v1:services:builds:create \
    --runtime node14

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

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

Validate you are on the correct Serverless Toolkit version

You should be using @twilio-labs/plugin-serverless version 2.4.0 or newer. You can run twilio plugins to verify your version.

Define your baseline Node.js version

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

  "runtime": "node12"

This will ensure that if you don't declare a specific Node.js runtime it will always use Node.js v12.

If you are working with multiple people or deploy 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 v14

To trigger a new deployment with Node.js v14 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 node14 --environment verify-14

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

Finalize your Node.js v14 transition

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

  "runtime": "node14"

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

How do I verify that the upgrade was successful?

Your runtime's 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:

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

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

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

  1. Create a new Service in the New Functions editor.
  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. After April 30, 2022, your code will be deployed using Node.js v14 by default.
  5. If you wish to test with Node.js v12, you can do so by navigating to the Dependencies tab, selecting Node v12 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 v14.

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.

Possible Side Effects

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 v14 once, any subsequent deployments that don't specify a specific runtime will automatically use Node.js v14 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.
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.

Thank you for your feedback!

We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more