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, you will need to deploy with Node v12. We recommend that you upgrade to Node v12 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 until April 30th, after which you would have to deploy using Node v12 at least once to move your code to Node v12.

If a Build contains only Assets, then the default Runtime(regardless of the Runtime passed in the Build request or even if Runtime is not passed) will be used automatically for the Build. The default Runtime is Node12 after April 30th.

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, you will need to select Node v12 runtime and make a deployment.

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. Copy any environment variables and/or dependencies your Function uses.
  4. Deploy your new Functions by clicking on deploy all. By default, your code will be deployed using Node v12.
  5. 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.
  6. Test while Classic version is unchanged. Once confident, you can switch over to the New Functions deployed using Node v12.

Be sure to update any references to your old Function (e.g. Studio Flow, Twilio number config) with 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 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 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. 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