【问题标题】:Build folder not recognized in pm2 service在 pm2 服务中无法识别构建文件夹
【发布时间】: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 不存在的错误。我检查了路径,它是正确的。

当我访问公共 IP 时,我的 react 应用程序会出现,这意味着它正在运行。但是为什么我在这里看到这个错误?

【问题讨论】:

    标签: node.js reactjs nginx vps pm2


    【解决方案1】:

    /root/repos/IRS-Ecommerce/IRS- Ecommerce/build/index.html双IRS- 电子商务orz

    【讨论】:

    • 只有双倍。这不是一个错误。如果我 cd 进入这个路径,它会打开我的构建文件夹。我在我的问题中添加了图片,你可以看到。
    猜你喜欢
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    • 1970-01-01
    • 2021-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多