I'm trying to display my nodejs app via localhost:3000.
My main JS file is "app.js". I ran in the terminal this: "node app" and the response was "server run", but when I type "localhost:3000" in my browser, the terminal shows this error message: "Error: Failed to lookup view "home" in views directory "C:...\views". Then I ran in the terminal "npm start", and got the same response of "server run", and then the same localhost:3000 browser error: "Error: Failed to lookup view "home" in views directory "C:...\views".
I installed those packages: (1) npm init y-, THEN package.json, (2) express-handlebars (and added views\main.handlebar + views\home.handlebars files).
My code in the file app.js is the following:
const express = require('express');
const exphbs = require('express-handlebars');
const app = express();
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
app.use(express.static('public'));
app.get('/', (req, res) => {
res.render('home', { title: 'Home Page' });
});
app.get('/about', (req, res) => {
res.render('about', { title: 'About Us Page' });
});
app.listen(3000, () => console.log('server run!'));
This is the printscreen that maybe will help more
Looking up in questions here, here and here didn't help me to solve my problem. What should L do to fix in and make localhost:3000 run properly in my browser?