Node raises the error cannot lookup view "index" in views directory "views" depending on the current directory in the shell
So I have been working on my Node.js project and my index.js
(on my root directory of my project) contains
const server = require("./server/server.js") //listens on port 8080 and other server stuff
So when I do $ cd server
and then do $ node server.js
, the server runs just fine on port 8080
. BUT when I try that on the root directory, $ node index.js
, It raises the error
Error: Failed to lookup view "index" in views directory "views"
and then shows that its on server/server.js
. And this is my code that renders the page:
app.get('/', function(req, res) {
res.render('index');
});
My poorly made file structure:
myProject/
|
|--index.js
|
|--server/
|---server.js
|---views/
|----index.ejs
from Recent Questions - Stack Overflow https://ift.tt/3dfqEQX
https://ift.tt/eA8V8J
Comments
Post a Comment