简体   繁体   English

在 Azure 上部署 React + Express

[英]Deploying React + Express on Azure

I'm having that problem where I'm trying to deploy Express and React boilerplate app like one app on Azure App Services.我在尝试部署 Express 和 React 样板应用程序时遇到了这个问题,就像 Azure 应用程序服务上的一个应用程序一样。 Locally everything works normaly, but when I try to deploy the whole thing, I see ":( Application Error " screen. I think it has to do something with the way my "scripts" inside server's package.json are set...(deploying only express server without client files works just fine). Here I'm trying to let Azure execute the build command once the app is deployed and not before that:本地一切正常,但是当我尝试部署整个事情时,我看到“:( 应用程序错误”屏幕。我认为这与我在服务器 package.json 中的“脚本”的设置方式有关......(仅部署没有客户端文件的快速服务器就可以了)。在这里,我试图让 Azure 在部署应用程序后而不是在此之前执行构建命令:

"scripts": { "start": "cd client && npm run build && cd../ && node server", "test": "echo something" }, "scripts": { "start": "cd client && npm run build && cd../ && node server", "test": "echo something" },

Probably I'm missing something crucial for Azure (I'm a beginner).I've read a lot and followed many tutorials but nothing seems to solve my problem.可能我错过了对 Azure 至关重要的东西(我是初学者)。我已经阅读了很多并遵循了很多教程,但似乎没有任何东西可以解决我的问题。 I'll really appreciate it if someone can give me a hand.如果有人能帮帮我,我将不胜感激。 Thank you!谢谢!

Link to my github repo: https://github.com/Ivailo663/finalExpressApp链接到我的 github 仓库: https://github.com/Ivailo663/finalExpressApp

"scripts": { "start": "cd client && npm run build && cd ../ && node server", "test": "echo something" }

This script will work if you already have all the modules your app needed, but if you don't have the modules, you need to install them first.如果您已经拥有应用程序所需的所有模块,则此脚本将起作用,但如果您没有这些模块,则需要先安装它们。

However, it is recommended that you build the client locally or use pipline to deploy the build folder to azure.但是,建议您在本地构建客户端或使用 pipline 将构建文件夹部署到 azure。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM