2022年4月30日からTwilioのNode.js v12サポート中止についての対応方法

TwilioのNode.js v12サポート中止についての対応方法

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Twilioのアナウンスメント

先日、Twilioから「2022年4月30日からTwilioがNode.js v12のサポートは中止となります」というメールが来ました。
経緯としては、Node.js公式にはNode.js v12 End-of-Life2022年4月30日になっているため、それに合わせて、TwilioもNode.js v12の支援を中止し、Node.js v14への移行を催促しています。

Node.js v12のままにしたらどうなりますか?

If you deploy Functions after April 30, any deployments using Node.js v12 will fail. Any new deployments made by Classic users will automatically use Node.js v14. We encourage all customers to upgrade to Node.js v14.

既にNode.js v12でデプロイした関数は、Node.js v12の環境のままに動きますが、これから(2022年4月30日以降)Node.js v12での関数デプロイは失敗することになります。

Twilio ServiceNode.js v14にテストと再デプロイする方法

Functions (Classic)の場合

The best way to upgrade is by switching away from Functions (Classic) and creating a new Functions Service.

  1. Create a new Service in the Twilio Console.
  2. Copy your Functions code in the new Service as new Functions.
  3. Deploy your new Functions by clicking on Deploy All. Make sure you select Node.js v14 in the the Dependencies tab.
  4. To test Node.js v12, click the Dependencies tab, select “Node12” from the runtime dropdown, and click Deploy All..
  5. Test before you change the Classic version. After you test, you can update your URLs to switch over to the new Functions deployed with Node.js v14.

Functions (Classic)をアプグレードしたい場合は、新しいFunctions Serverを作るのが一番おすすめです。
1. Twilio Consoleから新しいServiceを作ります。
2. Serviceにコードをコピーして新しいFunctionsとして作成します。
3. DependenciesNode.js v14にし、Deloy Allでデプロイします。
4. Node.js v12をテストしたい場合は、DependenciesNode.js v12を選びます。
5.バージョンを変える前にちゃんとテストし、Node.js v14でデプロイしたFunctionsのURLに更新します。

Functions UI Editor、Serverless Toolkit、またはAPIを使う場合

このドキュメンテーションを参考してください:
Runtime Node.js v14 upgrade

注意点

今後のNode.jsバージョンアップも公式と同期しています。ということは、Node.js v14は2023年4月30にサポート中止となります。
Node.js v16のスケジュールについては、Serverless Changelog entriesを参考してください。