thigi thigi - 2 months ago 11
Node.js Question

Express NodeJS Cannot find module 'html'

I have a Node Server with Express. I get the cannot find module 'html' error even though my code looks like this and should be correct in my opinion:

app.set('views', path.join(__dirname, 'build/views'));
app.use(favicon(path.join(__dirname, "build/favicon.ico")));
app.use('/scripts', express.static(path.join(__dirname, 'node_modules')));
app.use(express.static(path.join(__dirname, 'build')));

app.get('/', function(req, res){
res.render('index.html');
});

Answer

You have to set engine for HTML

Include this code in your main file

var engines = require('consolidate');

app.engine('html', engines.mustache);
app.set('view engine', 'html');
Comments