D
D
Denioo2019-09-20 12:05:31
Node.js
Denioo, 2019-09-20 12:05:31

Doesn't open pug?

Good afternoon. I decided to use the pug template engine when creating the application, and at the very beginning an error occurred. Before that, I used handlebars and there were no problems.
An error pops up

spoiler
Error: Failed to lookup view "main" in views directory

I also tried main.pug and let it be fully specified, nothing helps.
Here is the code
const express = require('express')
const path = require('path')
const fs = require('fs')
const pug = require('pug')

const app = express()

app.set('view engine', 'pug')
app.use(express.static(path.join(__dirname, 'public')))

app.listen(3000, ()=>{
    console.log('Node express work on 3000')
})

app.get('/', (req, res) => {
    res.render('main.pug')
})

I don't understand how to solve it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2019-09-20
@Denioo

Try adding: The structure should be like this:
приложение/views/main.pug

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question