简体   繁体   English

如何成功地将反应应用程序部署到 Azure

[英]How do I successfully deploy a react app to Azure

I am building a React .NET Core app.我正在构建一个 React .NET 核心应用程序。 The build is fine locally, but in Azure, the React/npm part of the build fails.本地构建很好,但在 Azure 中,构建的 React/npm 部分失败。 Below:以下:

> melanies_site@0.1.0 build D:\home\site\repository\ClientApp
remote:   > react-scripts build
remote:   
remote:   'react-scripts' is not recognized as an internal or external command,
remote:   operable program or batch file.
remote:   
remote:   npm ERR! melanies_site@0.1.0 build: `react-scripts build`
remote:   npm ERR! Exit status 1
remote:   npm ERR! 
remote:   npm ERR! Failed at the melanies_site@0.1.0 build script.
remote:   npm ERR! This is most likely a problem with the melanies_site package,
remote:   npm ERR! not with npm itself.
remote:   npm ERR! Tell the author that this fails on your system:
remote:   npm ERR!     react-scripts build
remote:   npm ERR! You can get their info via:
remote:   npm ERR!     npm owner ls melanies_site
remote:   npm ERR! There is likely additional logging output above.
remote:   npm ERR! System Windows_NT 6.2.9200
remote:   npm ERR! command "node" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
remote:   npm ERR! cwd D:\home\site\repository\ClientApp
remote:   npm ERR! node -v v0.10.40
remote:   npm ERR! npm -v 1.4.28
remote:   npm ERR! code ELIFECYCLE

package.json: package.json:

{
    "name": "melanies_site",
    "version": "0.1.0",
    "private": true,
    "engines": {
        "node": "10.15"
    },
    "dependencies": {
        "bootstrap": "^3.4.1",
        "react": "^16.0.0",
        "react-bootstrap": "^0.31.5",
        "react-dom": "^16.0.0",
        "react-router-bootstrap": "^0.24.4",
        "react-router-dom": "^4.2.2",
        "react-scripts": "1.0.17",
        "rimraf": "^2.6.2"
    },
    "scripts": {
        "start": "rimraf ./build && react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
    }
}

I'm new to react development and new to using Azure.我是反应开发的新手,也是使用 Azure 的新手。 I created this app using dotnet new react -o my-new-app我使用dotnet new react -o my-new-app创建了这个应用程序

I've tried installing react-scripts via npm.我尝试通过 npm 安装反应脚本。 Also tried adding也尝试添加

"engines": {
        "node": "10.15"
    },

to the package.json.到 package.json。

Here is what i would do to resolve something like this:这是我要解决这样的问题:

  • Update all my dependencies with the latest version( keeping * instead of version in package.json)使用最新版本更新我的所有依赖项(在 package.json 中保留 * 而不是版本)

  • Delete your package-lock.json删除你的package-lock.json

  • Try running npm install from administrator model尝试运行 npm 从管理员安装 model

  • try running npm audit fix尝试运行 npm 审计修复

  • Delete the Npm and npm-cache folder删除 Npm 和 npm-cache 文件夹

Additional reference: Please take a look at below thread:附加参考:请看下面的线程:

https://github.com/facebook/create-react-app/issues/1627 https://github.com/facebook/create-react-app/issues/1627

See if it works.看看它是否有效。

I was able to deploy my app to Azure.我能够将我的应用程序部署到 Azure。

When I posted this question, I was attempting to use Kudu for deployment (continuous integration).当我发布这个问题时,我试图使用 Kudu 进行部署(持续集成)。 I still have not found the solution to deploying this way.我仍然没有找到以这种方式部署的解决方案。

Now, I run the following terminal/console command in the root directory:现在,我在根目录中运行以下终端/控制台命令:

dotnet publish -c Release -o ./publish

Then I use my FTP client to deploy the files from /publish.然后我使用我的 FTP 客户端从 /publish 部署文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将asp.net core 2.1预览应用程序部署到azure? 我如何在azure中安装新的sdk - How to deploy asp.net core 2.1 preview app to azure?? how do i install the new sdk in azure 如何使用Azure SDK将Web应用程序部署到Azure - how to deploy web app to azure with azure sdk 如何为 Winforms 桌面应用部署可编辑的内容文件? - How do I deploy editable content files for a Winforms desktop app? 如何将基本HTML文件部署到Azure Bot函数应用程序的根目录? - How do you deploy a basic HTML file to the root directory of an Azure Bot function app? 我可以将 Angular 应用程序部署到 Azure 中已有的 WebAPI 应用程序吗? - Can I deploy an Angular App to an already existing WebAPI app in Azure? 如何仅将dll和静态文件提供给客户以部署到Azure - How do I give only dlls and static files to a customer to deploy to azure 如何获得 Azure DevOps 来构建 .NET 4.8 应用程序? - How do I get Azure DevOps to build a .NET 4.8 app? 如何从Mac将Web应用程序部署到Azure云服务? - How to deploy a web app to Azure Cloud Service from a Mac? 如何将 ASP.NET Web 应用程序部署到 Azure 与现有的 Z9778840A0104CB30C52ZB7 服务器数据库 (76410CB30C52ZB7) 服务器数据库 - How to deploy an ASP.NET Web App to Azure with an existing SQL Server database (Azure Data Studio) 我们如何使用管道从Azureure开发人员部署应用程序到具有不同订阅和组织的Azure Appservice - How do we deploy application from azure devops using Pipelines to azure appservice with a different subscription and organization
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM