简体   繁体   English

部署 React.js 和 Node.js Web 应用程序

[英]Deployment of React.js and Node.js Web app

I'm building a web app using React.js and Node.js.我正在使用 React.js 和 Node.js 构建一个 web 应用程序。 I wanted to know that how I deploy my web application on a server?我想知道如何在服务器上部署我的 web 应用程序? Like when I run it on my local server then it needs two server, one is for React.js and another is for Node.js.就像我在本地服务器上运行它时,它需要两台服务器,一台用于 React.js,另一台用于 Node.js。 Is it goes same with deployment also?部署也一样吗?

No, you will only need one server (unless you're using a server side rendering framework like Next.js).不,您只需要一台服务器(除非您使用的是像 Next.js 这样的服务器端渲染框架)。 If you used create-react-app, use should be able to run npm build and it'll create a static build.如果您使用 create-react-app,使用应该能够运行npm build ,它将创建 static 构建。 Here's some relevant links:以下是一些相关链接:

You need to run script to build and bundle your client side by calling npm run build in terminal, then you should serve those build files in index/main file in backend side.您需要通过调用npm run build来运行脚本来构建和捆绑客户端,然后您应该在后端的索引/主文件中提供这些构建文件。 Then you can deploy your application.然后您可以部署您的应用程序。 You can read this awesome article to understand in depth: https://www.freecodecamp.org/news/deploying-a-mern-application-using-mongodb-atlas-to-heroku/您可以阅读这篇很棒的文章以深入了解: https://www.freecodecamp.org/news/deploying-a-mern-application-using-mongodb-atlas-to-heroku/

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

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