首页 > 解决方案 > 不同端口上的 NodeJS 和 React 并发服务器

问题描述

故事:最近,我们开始使用'create-react-app'. 当时它在我们的开发机器上运行良好。

一段时间后,我们开始使用 express 开发 NodeJS API,然后将其连接到我们的 React 前端。在我们的开发机器上,一切仍然运行良好。

问题:由于我们现在完成了开发,并希望将应用程序托管在第 3 方服务器(A2Hosting)上;我们在同时启动服务器和 React 应用程序时遇到问题。

如果我们单独启动服务器,它正在工作并且我们能够调用 api。如果我们单独启动 React 应用程序,我们仍然会得到理想的结果。但是如果我们尝试同时运行,问题仍然存在。下面是我们尝试同时运行服务器和客户端时的错误报告:

$ concurrently --kill-others-on-fail "yarn server" "yarn client"
[0] node[3989326]: pthread_create: Resource temporarily unavailable
[1] node[3989327]: pthread_create: Resource temporarily unavailable
[0] yarn server exited with code SIGABRT
--> Sending SIGTERM to other processes..
[1] yarn client exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 

标签: node.jsreactjsexpressshared-hosting

解决方案


推荐阅读