[英]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.