在 heroku 上托管我的网站,从日志中获取此错误
Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
我的 server.js
if (process.env.NODE_ENV == "production") {
app.use(express.static("client/build"));
const path = require("path");
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
}
package-json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client npm run build --prefix client"
},
文件路径: 服务器>客户端
现在也许heroku没有构建文件夹?我怀疑,因为我得到了 Build 成功!在我的终端上发送消息。