我正在构建一个 .net Core + React 应用程序,并使用 Azure DevOps Pipelines 进行 CICD 流程。 该应用程序在发布版本中本地运行并调试这两种配置。我在自己的虚拟机中启动并运行了 IIS 服务器。当我尝试使用 Azure Pipelines 部署它时,它给出了以下错误消息。之前它工作得很好,但突然间它向我展示了这个错误。谁能帮帮我吗?
最佳答案
当我在 Azure 应用服务上将 ASPNETCORE_ENVIRONMENT 设置为“开发”时,我看到此错误。我怀疑这是由React模板Startup.cs中的以下if语句引起的:
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});
我认为我们不需要在 Azure 中启动 React Development 服务器。
我的解决方案是注释掉 Startup.cs 中的 if 语句,或者将 ASPNETCORE_ENVIRONMENT 设置更改为 Development 以外的其他设置。
关于reactjs - 无效操作异常 : The NPM script 'start' exited without indicating that the create-react-app server was listening for requests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61190970/