reactjs - 无效操作异常 : The NPM script 'start' exited without indicating that the create-react-app server was listening for requests

标签 reactjs asp.net-core azure-devops azure-pipelines azure-pipelines-build-task

我正在构建一个 .net Core + React 应用程序,并使用 Azure DevOps Pipelines 进行 CICD 流程。 该应用程序在发布版本中本地运行并调试这两种配置。我在自己的虚拟机中启动并运行了 IIS 服务器。当我尝试使用 Azure Pipelines 部署它时,它给出了以下错误消息。之前它工作得很好,但突然间它向我展示了这个错误。谁能帮帮我吗?

Please look into the error message

最佳答案

当我在 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/

相关文章:

javascript - react : undefined the state of `this.setState` instantly

javascript - 外部 javascript 文件无法在 .net core MVC 中工作

asp.net - 如何从一个页面处理程序发送到另一个页面处理程序?

Azure DevOps REST API : Is there a way to show all fields of a workitem by running a WIQL through REST API

azure - 如何创建变量组、更新管道中的值并查询该值?

javascript - ReactDOM.render() 中的一个根元素还是整个布局?

javascript - React-testing-library:因输入而改变

android - 是否可以从 React App 访问 NFC 功能

c# - 将数据传递到链下游的中间件

node.js - Azure DevOps Pipeline 全局包安装最佳实践