Menu

Expand
Rate this page:

Twilio Functions Node v12 upgrade

What do you need to know?

We are keeping your runtime up to date with industry standards. In accordance with OpenJS Foundation’s support schedule, Node v10 will no longer be supported after April 30, 2021.

What do you need to do?

Test and re-deploy your code with Node12 before April 30th, 2021.

After April 30th, 2021, if you make changes to your Functions, they will deploy to NodeJS 12. We recommend that you upgrade to NodeJS 12 even if you’re not planning on making other changes.

A deployment will be required to make Functions run against the new Node version.

Currently, the Node version will only change if you explicitly set the Node version via either the UI dropdown in the dependencies tab, by passing runtime using serverless toolkit or by explicitly setting the runtime parameter when creating a Build.

If you don’t specify a runtime, we’ll use Node v12 by default if there are no previous builds deployed in the service. If you do have a build deployed in the service, the same runtime will be used to deploy as the last successful deployment.

What happens if I do nothing?

Your currently deployed functions will continue to execute on the existing Node v10 runtime if no changes are made. If you deploy functions after April 30, they will automatically deploy to Node v12.

Follow the instructions below to upgrade, test and deploy your code in Node v12 before the April 30 deadline. We encourage all customers to upgrade to Node v12.

While there are no syntax changes required for the upgrade from Node v10 to Node v12, a possible area of impact is in NPM dependencies. It is important to check that the dependencies you include are supported on Node12.

How to test and re-deploy?

Example Function to test your current Node version

An example function to check your node version is this:

exports.handler = function (context, event, callback) {

   return callback(null, process.version);

};

Using Function(Classic)

Here is a video explaining the steps to upgrade your functions to node 12.

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

  1. Create a new service in the New Functions editor.
  2. Copy your functions code in the new service as new Functions.
  3. Deploy your new Functions by clicking on deploy all. By default your code will be deployed using Node v12.
  4. If you wish to test with Node v10, you can do so by navigating to the dependencies tab, selecting Node10 from the runtime dropdown, and clicking "deploy all" for the change to take effect.
  5. Test while Classic version is unchanged. Once confident, you can switch over to the New Functions deployed with Node v12.

If you would like to change runtime within Functions(Classic), please reach out to support with your account sid and they would be able to change the runtime for you.

Using Functions UI Editor

If your application is built with the latest Functions Editor, there are two ways to test your application.

node10_dropdown.png
Option 1: By creating a New Service

  1. Create a new Service.
  2. Copy paste your Functions from the existing service.
  3. Select the new runtime in the Dependencies tab to test.
  4. Save and Deploy all.

Option 2: Test with Existing Service

  1. Select Node v12 in the Dependencies tab.
  2. Deploy and test in a single environment.

Via the API

You can use the runtime parameter on the Build to deploy and test your code.

  1. Create a new Service.
  2. Deploy Functions to the new Service with runtime parameter on the build set to “node12”.

Using Serverless Toolkit

To deploy to your choice of node v10 or node v12 follow these steps:

  1. Update the Twilio CLI Serverless plugin: twilio plugins:update
  2. Check that you have version 1.9.0 or newer of @twilio-labs/plugin-serverless by running twilio plugins
  3. If your version is not at least 1.9.0 please should instead run: twilio plugins:remove @twilio-labs/plugin-serverless followed by twilio:plugins install @twilio-labs/plugin-serverless@latest
  4. Deploy your project to node12 using the --runtime node12 flag using command twilio serverless:deploy --runtime node12

Your functions are now deployed with runtime set to node12.

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 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. How could this documentation serve you better?

        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