Optional chaining in not working in Node V18 azure web app

Mounika Chirukuri 0 Reputation points
2023-08-26T10:41:22.21+00:00

We have used latest node modules and it contains optional chaining. While deploying to azure it throws an error. PFAScreenshot 2023-08-26 161027

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,491 Reputation points Moderator
    2023-10-13T22:38:56.8+00:00

    Hi @Mounika Chirukuri like Lex mentioned, if you don't have a specific reason for using App Service (Windows) try deploying to App Service Linux. But here are some options to get optional chaining support in Azure App Service with Node version 18:

    • Upgrade the Node.js version on App Service to version 18.7.0 or higher. Optional chaining was introduced in Node 18.7.
    • Use a polyfill library like optional-chaining-polyfill to add support for older Node versions. Install it as a dependency.
    • Transpile your code with Babel to convert the optional chaining syntax to supported JavaScript that will work on older Node versions.
    • Use JavaScript try/catch instead of optional chaining to handle potential null/undefined errors.

    -Grace

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.