简体   繁体   English

AWS EC2 react 应用程序部署有警告吗? 怎么解决?

[英]AWS EC2 react app deployment have warnings? How to solve?

I have ssh into the EC2 instance and pull the repo from my GitHub which contains my react app.我将 ssh 放入 EC2 实例中,并从包含我的反应应用程序的 GitHub 中提取存储库。 Then I go into the folder in server and ran npm start trying to start deployment, but occurs these warnings, but when I run npm start locally, the web page shows correctly. Then I go into the folder in server and ran npm start trying to start deployment, but occurs these warnings, but when I run npm start locally, the web page shows correctly. (this is my first time doing the AWS deployment so I am not sure if this is ok even if with these warnings and if so what I should do next to make my web page appear?) (这是我第一次进行 AWS 部署,所以即使有这些警告,我也不确定这是否可以,如果可以,我接下来应该怎么做才能让我的 web 页面出现?) 在此处输入图像描述

You can ignore the warnings, it doesnt affect your app running but it's worth to fix because it improves your app quality and remove some bundles that are not used.您可以忽略警告,它不会影响您的应用程序运行,但值得修复,因为它可以提高您的应用程序质量并删除一些未使用的捆绑包。


To deploy your website, you have to use npm run build .要部署您的网站,您必须使用npm run build

npm run build creates a build directory with a production build of your app. npm run build会创建一个包含应用程序生产构建的构建目录。

After you successfully built your app, use nginx to host your build directory.成功构建应用程序后,使用nginx托管构建目录。

sudo apt install nginx

If you are on ubuntu, that will install nginx.如果您在 ubuntu 上,则将安装 nginx。

And update /etc/nginx/sites-enabled/default with the below content:并使用以下内容更新/etc/nginx/sites-enabled/default

server {
        listen 80 default_server;
        server_name _;
        include /etc/nginx/mime.types;

        root  ABSOLUTE_PATH_TO_YOUR_BUILD_DIRECTORY;
        index  index.html index.htm;

        location / {
                try_files $uri $uri/ /index.html;
        }
}

Now restart the nginx and you will see your app running on your EC2 ip address.现在重新启动nginx ,您将看到您的应用程序在您的 EC2 ip 地址上运行。

sudo service nginx restart

These are not errors, so you do not NEED to fix them.这些不是错误,因此您无需修复它们。 They are (I think) ESLint warnings.它们是(我认为)ESLint 警告。 They are meant to make your code better, but it will not cause an error when you run it.它们旨在使您的代码更好,但在运行时不会导致错误。

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

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