当我尝试 swa 时,开始启动一个使用“C#”Blazor 和 API 层创建的新静态 Web 应用程序。 出现以下错误:
✖ 发现 Azure Functions Core Tools v4 与当前的 Node.js v20.12.2 不兼容。 ✖ 请参阅 https://aka.ms/functions-node-versions 了解更多信息。 PS D:\DEV\TedcoStaticWebAppV4> swa 启动
我安装了这些版本,这个核心工具版本和运行时肯定与 Node.js v20.12.2 兼容。
Azure Functions 核心工具 核心工具版本:4.0.5441 提交哈希:N/A(64 位) 函数运行时版本:4.25.3.21264
将节点版本降级到18.18.0,它对我有用。
我创建了一个 Blazor 应用程序,并且能够在本地运行
swa start
。请参阅文章。
Node Version: 18.18.0
func version: 4.0.5611
我在
swa start
中使用了package.json
命令来运行该项目。
Package.json:
{
"name": "swa-local-first-demo",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "swa start http://localhost:5092 --api-location http://localhost:7062"
},
"keywords": [],
"author": "",
"license": "ISC"
}
控制台输出:
C:\Users\uname\Source\Repos\Solution1>npm start
> [email protected] start
> swa start http://localhost:5092 --api-location http://localhost:7062
Welcome to Azure Static Web Apps CLI (1.1.7)
***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure. *
***********************************************************************
[swa] - Waiting for http://localhost:5092 to be ready
[swa] √ http://localhost:5092 validated successfully
[swa] - Waiting for http://localhost:7062 to be ready
[swa] √ http://localhost:7062 validated successfully
[swa]
[swa] Using dev server for static content:
[swa] http://localhost:5092
[swa]
[swa] Using dev server for API:
[swa] http://localhost:7062
[swa]
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
[swa]
[swa]
[swa] GET http://localhost:5092/ (proxy)
[swa] GET http://localhost:4280/ - 200
[swa] GET http://localhost:5092/css/app.css (proxy)
[swa] GET http://localhost:5092/_framework/blazor.webassembly.js (proxy)
[swa] GET http://localhost:5092/_framework/aspnetcore-browser-refresh.js (proxy)
[swa] GET http://localhost:4280/css/app.css - 200
[swa] GET http://localhost:4280/_framework/blazor.webassembly.js - 200
输出: