I try to use handlebars template in Express. I get this Error-Message:
TypeError: this.engine is not a function at View.render (/home/ubuntu/workspace/node_modules/express/lib/view.js:128:8) ...
with this code:
'use strict'; var express = require('express'); var expressHandlebars = require('express-handlebars'); var app = express(); app.engine('handlebars', expressHandlebars({defaultLayout: 'layout'})); app.set('view engine', 'html'); app.use(express.static('views')); app.route('/single/:id') .get(function (req, res) { res.render(process.cwd() + `/public/single-poll`, { id: req.params.id }); }); app.listen(process.env.PORT, function () { console.log('Node.js listening on port ' + process.env.PORT + '...'); }); When I replace the render() function with sendFile() is works fine. I'm aware of Express js render : TypeError: this.engine is not a function and Express js render error this.engine is not a function and TypeError: this.engine is not a function when trying to use Moustache in Express JS, but they didn't help for me.
What can be the problem?