Node JS: ReferenceError: require is not defined
5 answers
Home.ejs is not the approriate file to write this line. Ejs files won't contain as much logic (other than condition and loop over some element in your dom). Basically what you want to do is an anodeJs script file that will connect to mysql, handle the request and serve your ejs files with your data.
Using Express, your node file will have something like this:
app.get("/home",(req,res)=>{ res.render("home.ejs", {data : data})
(where data is what you get from your DB
+4
source to share