'ReactJS, Heroku: Error: ENOENT: no such file or directory, stat build\index.html
I am following this tutorial and am now at the end. https://www.udemy.com/course/the-ultimate-react-js-responsive-portfolio-website/learn/lecture/28599190#questions
But I get this error message: Error: ENOENT: no such file or directory, stat build\index.html
Here is the repo https://github.com/GuaBaiChi/portfoliopro
I tried to install build but it hasn't helped.
Here is the server.js
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const path = require("path");
const ContactRoute = require("./router/ContactRoute");
const app = express();
app.use(express.json());
app.use(cors());
app.use("/", ContactRoute);
if (process.env.NODE_ENV === "production") {
app.use(express.static(path.join(__dirname, "build/public")));
}
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "client/build/index.html"));
});
// const port = process.env.PORT || 5000;
// app.listen(port, console.log(`server listing to port 5000 only`));
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`server port ${PORT}`);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
