如何使用 pm2 提供构建文件夹

发布于 2025-01-12 05:56:20 字数 467 浏览 3 评论 0原文

我正在尝试为我的node.js 提供服务并使用pm2 反应应用程序,包括从mongoDB 加载数据。 到目前为止,我可以使用 serve -s build -l 3001 来提供构建服务,我正在使用端口 3001 作为前端。 pm2 start server.js 用于在端口 3000 上运行的后端。这会成功运行并加载数据。

但是,我不想使用 pm2 start server.js能够使用我的应用程序名称运行 pm2serve build/ 3000 但是当我这样做时,我的网页变成空白,所有响应都是 200 并且日志中没有任何内容。 我还在线检查并搜索了许多资源,所有结果都回到了我目前正在做的事情。

我正在使用 npm run build 来创建我的构建文件夹。

有谁知道如何使用 pm2 成功地为您的 React 构建目录提供服务?

谢谢你!

I am trying to serve my node.js and react application with pm2 including loading data from mongoDB.
So far I can serve the build with serve -s build -l 3001 i am using port 3001 for the front end.
And pm2 start server.js for the backend which runs on port 3000. This runs and loads data successfully.

However, instead of using pm2 start server.js I want to be able to run pm2 serve build/ 3000 with my app name however when I do this my web page turns blank, all responses are 200 and there is nothing in the logs.
I have also checked online and searched many resources all result back to exactly what i am currently doing.

I am using npm run build to create my build folder.

Does anyone know a way to successfully serve your react build directory with pm2 ?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文