ENOENT: no such file or directory, stat '/opt/render/project/src/frontend/build/index.html'

Error: ENOENT: no such file or directory, stat ‘/opt/render/project/src/frontend/build/index.html’

got this error after trying to deploy it
wriiten the same code of server.js as you explained please explain.

my server.js code

const express = require(“express”);
const cors = require(“cors”);
const morgan = require(“morgan”);
const dotenv = require(“dotenv”);
const colors = require(“colors”);
const path = require(“path”);
const connectDb = require(“./config/connectDB”);
// config dot env file

//databse call

//rest object
const app = express();


//user routes
app.use(“/api/v1/users”, require(“./routes/userroute”));
//transections routes
app.use(“/api/v1/transactions”, require(“./routes/transactionRoute”));

//static files
app.use(express.static(path.join(__dirname, “./frontend/build”)));

app.get(“*”, function (req, res) {
res.sendFile(path.join(__dirname, “./frontend/build/index.html”));

const PORT = process.env.PORT||8090;

//listen server
app.listen(PORT, () => {
console.log(Server running on port ${PORT});

and my index.html is in folder frontend->build->index.html.
and also i ran npm run build command as well.


You’ll need to double-check that the path matches exactly (including casing) and that it exists, or that any required frontend build scripts are being run.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.