How to resolve Node Error when deploying azure static web app with the statice web app CLI

Dean 1 Reputation point
2025-02-16T06:59:24.37+00:00

I am executing the Static Web App CLI to deploy a simple HTML website.

swa deploy --api-language none --api-version none --env Production --verbose > deployment-log.txt 2>&1

The error I get is below. How do I fix this?

Welcome to Azure Static Web Apps CLI (2.0.3)

Using configuration "static-web-apps-play-ground" from file:
  C:\Users\####\source\repos\StaticWebApps-PlayGround\swa-cli.config.json

Deploying front-end files from folder:
  C:\Users\####\source\repos\StaticWebApps-PlayGround\src


Deploying to environment: Production

Deploying project to Azure Static Web Apps...
node.exe : - Preparing deployment. Please wait...
At C:\nvm4w\nodejs\swa.ps1:16 char:5
+     & "$basedir/node$exe"  "$basedir/node_modules/@azure/static-web-a ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (- Preparing deployment. Please wait...:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

The swa-cli-config.json is

{
  "$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
  "configurations": {
    "static-web-apps-play-ground": {
      "appLocation": "./src/",
      "appName": "swa-playground",
      "resourceGroup": "rg-swa-playground"
    }
  }
}

Node version is 20.18.3, but I have also tried it with versions 18.17.1, 16.20.2 and 15.14.0.

SWA CLI version is 2.0.3

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,076 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Dean 1 Reputation point
    2025-02-18T11:29:39.97+00:00

    I modified the swa cli js files to include extra logging and found the root cause was because I did not have an index.html file, I only had a home.html file.

    0 comments No comments

  2. Laxman Reddy Revuri 2,540 Reputation points Microsoft Vendor
    2025-02-18T12:21:12.56+00:00

    Hi @Dean
    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer

    Ask : How to resolve Node Error when deploying azure static web app with the statice web app CLI
    I modified the swa cli js files to include extra logging and found the root cause was because I did not have an index.html file, I only had a home.html file.

    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members. 


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.