Error Cannot find module html

0 votes

I have a basic node.js app that I am trying to get off the ground using Express framework. I have a views folder where I have an index.html file. But I receive the following error when loading the web browser.

Error: Cannot find module 'html'

Below is my code.

var express = require('express');
var app = express.createServer();

app.use(express.staticProvider(__dirname + '/public'));

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

app.listen(8080, '127.0.0.1')

What am I missing here?

Sep 3, 2020 in Java-Script by kartik
• 37,510 points
5,348 views

1 answer to this question.

0 votes

Hello @kartik,

You can have jade include a plain HTML page:

in views/index.jade

include plain.html

in views/plain.html

<!DOCTYPE html>
...

and app.js can still just render jade:

res.render(index)

Hope it helps!!
Thank you!!

answered Sep 3, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

Error: Unexpected token import in nodejs

Hello, Unfortunately, Node.js doesn't support ES6's import yet. To accomplish what ...READ MORE

answered Apr 24, 2020 in Java-Script by Niroj
• 82,880 points
9,018