在IIS服务器上进行React部署 [英] React Deployment on IIS server
问题描述
我想将我的react应用程序部署到IIS,并尝试了逐步指南.
我已经尝试过create-react-app,并且已经添加了一个新网站,但是当我运行它时,它说:
该网站无法访问
.
我尝试过这种方法,但有些步骤不为人所知.=>
2.运行以下命令以添加软件包
npm i -g create-react-app
3.运行以下命令以在文件夹中创建react应用,等待创建应用
create-react-app my-app
-
将项目构建到生产文件夹.
npm运行构建
5.打开IIS管理控制台并创建一个新的网站,并将生成路径用作物理路径.例如: D:\ ReactAppTest \ my-app \ build
注意:您应该注意您的端口号.
- 然后,您可以使用该端口号访问您的React应用程序.例如:
I would like to deploy my react app to IIS and I tried a step by step guide.
I already tried a create-react-app and I already added a new website but when I run It says:
this site can't reach
.
I tried that way but some steps are not understood.=>create-react-app on IIS 10
I am newbie and May I know step by step if possible.
Thanks.
解决方案I suggest you could try belwo steps to host a reasct app on the IIS.
If you don't have the react app, I suggest you could install the npm and generate a react app for testing.
1.Open cmd and locate a folder by using cd yourfoldername
2.Run below command to add the package
npm i -g create-react-app
3.Run below command to create the react app in the folder, wait for creating the application
create-react-app my-app
Build the project to production folder.
npm run build
5.Open IIS management console and create a new web sites and use the build path as the physical path. for example:
D:\ReactAppTest\my-app\build
Notice: You should pay attention to your port number.
- Then you could use that port number to access your react application. For example: http://localhost:9965/
这篇关于在IIS服务器上进行React部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!