A
A
Alexey2022-04-05 17:57:15
Node.js
Alexey, 2022-04-05 17:57:15

Doesn't see handlebars?

I'm studying node, I don't understand what the error is, please tell me friends (I'm writing from a book)

const express = require('express')
const expressHandlebars = require('express-handlebars')
const app = express()
const port = process.env.PORT || 3000

app.engine('Handlebars', expressHandlebars({
    defaultlayout: 'main'
}))
app.set('view engine', 'handlebars')

app.get('/', (req, res) => res.render('Home'))
app.get('/about', (req, res) => res.render('about'))

// user 404
app.use((req, res) => {
res.status(404)
res.render('404')
})
// 500 bad request
app.use((err, req, res, next) => {
    console.log(err.message)
    res.status(500)
    res.render('500')
})

app.listen(port, () => console.log(
    `Express запущен на http://localhost:${port};` + 
    `Нажмите CTRL + C, для завершения`
))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question