Search code examples
node.jsazureazure-static-web-app

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


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

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

The output is

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 and 16.20.2 SWA version is 2.03


Solution

  • 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.