Committing for my Azure Static Web App does not work, the action fails because of wrong Node.js version

Michael Karl 0 Reputation points
2024-10-26T19:41:21.3733333+00:00

I am doing the excercise "Publish an API to Azure Static Web Apps".

I got to run it locally after some struggles, but whenever I commit it to git, the action says "The following actions use a deprecated Node.js version and will be forced to run on node20: actions/checkout@v3, actions/setup-node@v3. For more info: https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/"

I am not sure how so solve this.

This question is related to the following Learning Module

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,699 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AmaranS 6,590 Reputation points Microsoft Vendor
    2024-10-28T07:10:58.4466667+00:00

    Hi Michael Karl,

    Thank you for reaching out to us on the Microsoft Q&A forum.

    To fix the deployment issue with the deprecated Node.js version in GitHub Actions, you can specify a compatible Node.js version in the GitHub Actions workflow file. Here’s how to update it:

    Edit the workflow file: In your repository, go to .github/workflows and open the workflow file for your Azure Static Web App deployment.

    1. Specify the Node.js version: Update the workflow to use a supported Node.js version. For instance, you can use version 16.x, as it is generally stable and compatible with most Azure Static Web App setups. Look for any actions/setup-node@ steps in your YAML file, and update it like this:
         -
      
      Save and Commit: After editing the workflow file, commit and push the changes to trigger the deployment with the updated Node.js version.
    2. Verify the deployment: Check the GitHub Actions log to ensure the deployment runs without errors. GitHub Actions plans to enforce Node.js 20, the deprecation warning suggests preparing your workflow for compatibility with Node 20. Here’s a quick approach to address this:
      1. Update Dependencies for Compatibility: Some dependencies might have compatibility issues with Node.js 20. Ensure any libraries or packages used are compatible with Node 20.
      2. Explicitly Set Node Version in the Workflow: While Node.js 20 will be the default, you can still control this version by explicitly setting node-version: '20.x' in actions/setup-node@v3. Here’s how:
              -
        
        c. Verify Locally with Node 20: To avoid surprises, run your application locally using Node.js 20 if you haven’t yet. If you encounter compatibility issues, updating packages or adjusting configurations might be necessary. d. Test and Commit: After updating the workflow, commit it to see if the warning clears in GitHub Actions.
      This setup should help smooth the transition and prevent any disruptions once Node 20 is fully enforced.

    If you have any other questions or are still running into more issues, please let me know.

    If you've found the provided answer helpful, please click the "Accept Answer/Upvote" button. This will be beneficial to other members of the Microsoft Q&A forum community.

    Thank you.

    0 comments No comments

Your answer

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