Reputation: 3707
I want to build a local development environment for Azure Static Web Apps using SWA CLI. The Client is a Blazor WASM.
I installed SWA CLI successfully using the command:
npm install -g @azure/static-web-apps-cli
The Blazor client is working fine when started from Visual studio using F5
Running swa init command produced this file swa-cli.config.json
{
"$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
"configurations": {
"blazor-app3": {
"appLocation": ".",
"outputLocation": "bin\\wwwroot",
"appBuildCommand": "dotnet publish -c Release -o bin",
"run": "dotnet watch run",
"appDevserverUrl": "http://localhost:5050"
}
}
}```
When I run 'swa start' command I get this
`
C:\Users\emad\source\repos\BlazorApp3\BlazorApp3>swa start
Welcome to Azure Static Web Apps CLI (1.1.8)
Using configuration "blazor-app3" from file:
C:\Users\emad\source\repos\BlazorApp3\BlazorApp3\swa-cli.config.json
***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure. *
***********************************************************************
[run] dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
[run] 💡 Press "Ctrl + R" to restart.
[run] dotnet watch 🔧 Building...
[swa]
[swa] Found configuration file:
[swa] C:\Users\emad\source\repos\BlazorApp3\BlazorApp3\staticwebapp.config.json
[swa]
[swa] - Waiting for http://localhost:5050 to be ready
[run] Determining projects to restore...
[run] All projects are up-to-date for restore.
[run] BlazorApp3 -> C:\Users\emad\source\repos\BlazorApp3\BlazorApp3\bin\Debug\net8.0\BlazorApp3.dll
[run] BlazorApp3 (Blazor output) -> C:\Users\emad\source\repos\BlazorApp3\BlazorApp3\bin\Debug\net8.0\wwwroot
[run] dotnet watch 🚀 Started
[swa] √ http://localhost:5050 validated successfully
[run] info: Microsoft.Hosting.Lifetime[14]
[run] Now listening on: http://localhost:5050
[swa]
[swa] Using dev server for static content:
[swa] http://localhost:5050
[swa]
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
[swa]
[swa]
[run] info: Microsoft.Hosting.Lifetime[0]
[run] Application started. Press Ctrl+C to shut down.
[run] info: Microsoft.Hosting.Lifetime[0]
[run] Hosting environment: Development
[run] info: Microsoft.Hosting.Lifetime[0]
[run] Content root path: C:\Users\emad\source\repos\BlazorApp3\BlazorApp3
[run] dotnet watch ⌚ Connecting to the browser is taking longer than expected ...
`
The browser is opening localhost:5050
The problem is : If I try to open the localhost:4280 to see the "emulated" site. I always get an error ERR_CONNECTION_REFUSED
[![enter image description here](https://i.sstatic.net/efEcfYvI.png)](https://i.sstatic.net/efEcfYvI.png)
Upvotes: 1
Views: 278
Reputation: 2009
To avoid downgrading the global node version because of Static Web Apps (SWA), you may install the SWA and the downgraded node in the project level:
npm install -D @azure/static-web-apps-cli
And then the node version:
npm install -D node@18
Note: Verify the version with the
npx node -v
command
Finally, you can start the emulation with npx
to run the command with the local packages:
npx swa start ./build --data-api-location swa-db-connections
Upvotes: 0
Reputation: 3707
I had nodejs v20 when I was having this issue. Downgrading to nodejs v16 fixed the issue.
Upvotes: 1