【发布时间】:2021-01-03 00:22:10
【问题描述】:
我正在使用 ssh 在 vps ubuntu 机器上运行我的 node+react 应用程序。 我使用 nginx,pm2 来运行我的节点 js 服务器,但是当我检查我的日志时,它显示以下错误:
App [server:0] starting in -fork mode-
PM2 | 2020-09-16T07:05:03: PM2 log: App [server:0] online
PM2 | 2020-09-16T07:06:18: PM2 log: Reloading logs...
PM2 | 2020-09-16T07:06:18: PM2 log: Reloading logs for process id 0
PM2 | 2020-09-16T07:38:58: PM2 log: Stopping app:server id:0
PM2 | 2020-09-16T07:38:58: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
PM2 | 2020-09-16T07:38:58: PM2 log: pid=6888 msg=process killed
PM2 | 2020-09-16T07:38:58: PM2 log: App [server:0] starting in -fork mode-
PM2 | 2020-09-16T07:38:58: PM2 log: App [server:0] online
0|server | Error: ENOENT: no such file or directory, stat '/root/repos/IRS-Ecommerce/IRS-
Ecommerce/build/index.html'
/root/.pm2/logs/server-out.log last 15 lines:
0|server | Server is up and running at port : 8080
0|server | MongoDB connected successfully!
我的节点 js 服务器文件,我将在其中发送我的 react 应用程序作为响应:
app.use(express.static("IRS-Ecommerce/build"));
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "IRS-Ecommerce", "build", "index.html"));
});
我已经在我的 react 应用程序中运行 npm build 并且 build 文件夹存在,但它显示 index.html 不存在的错误。我检查了路径,它是正确的。
【问题讨论】:
标签: node.js reactjs nginx vps pm2