【问题标题】:create react app deploy to digitalocean problem with pm2使用pm2创建react app部署到digitalocean问题
【发布时间】:2020-01-31 04:59:38
【问题描述】:

我对此很陌生,我正在按照本教程 (https://hackernoon.com/start-to-finish-deploying-a-react-app-on-digitalocean-bcfae9e6d01b) 练习通过在 digitalocean 中的 create-react-app 部署我的标准创建的应用程序。

在运行 [pm2 serve build] 时显示:

pm2 serve build
[PM2] Applying action restartProcessId on app [static-page-server-8080](ids: 0)
[PM2] [static-page-server-8080](0) ✓
[PM2] Process successfully started
[PM2] Serving /home/carles/build on port 8080

但在提到的端口上什么也看不到。这是我在运行 [pm2 list] 时得到的:

App name                │ id │ version │ mode │ pid │ status  │ restart │ uptime │ cpu │ mem    │ user   │ watching │
├─────────────────────────┼────┼─────────┼──────┼─────┼─────────┼─────────┼────────┼─────┼────────┼────────┼──────────┤
│ static-page-server-8080 │ 0  │ 3.3.1   │ fork │ N/A │ errored │ 0       │ 0      │ 0%  │ 0 B    │ carles │ disabled │

在本教程的第 3 点之前一切正常。任何想法如何使这项工作?我感谢您的帮助! 谢谢!!

【问题讨论】:

    标签: deployment pm2


    【解决方案1】:

    我建议您按照以下说明操作:server-react-app

    但是,在服务器中运行您的应用程序之前,您是否需要built 它,正在运行:

    yarn build
    

    npm run build
    

    构建完成后,它将创建一个名为 build 的文件夹,然后,您是否需要通知您的服务器在构建文件夹中运行。那么

    1. 运行yarn buildnpm run build

    2. npm install -g serve

    3. pm2 serve build

    4. Access it: http://someip:8080

    在这种情况下,它将从build 和端口8080 运行您的应用程序。 有了这个,你的应用程序就可以工作了。

    【讨论】:

      猜你喜欢
      • 2020-08-17
      • 2020-01-31
      • 1970-01-01
      • 2020-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 2020-04-06
      相关资源
      最近更新 更多