Express Render not working return error: No default engine was specified and no extension was provided

I’m writing an Express application without a template engine I am using just using HTML as the template engine.

app.set('view engine', 'html');

actually, the whole code was generated using express-generator and I set the view to --no-view Flag and the index URL page runs well but trying another URL like users or any other except the index URL does work all it shows is No default engine was specified and no extension was provided. But if I Add the above code app.set('view engine', 'html'); it returns Error: Cannot find module 'html'. Below are the codes.

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var addressRouter = require('./routes/address');

var app = express();
    app.set('view engine', 'html');
    app.use(logger('dev'));
    app.use(express.json());
    app.use(express.urlencoded({ extended: false }));
    app.use(cookieParser());
    app.use(express.static(path.join(__dirname, 'public')));

    app.use('/', indexRouter);
    app.use('/users', usersRouter);

    module.exports = app;

And the userRouter user.js

var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
  res.render('index');
});

module.exports = router;

For Home Page

router.get('/', function(req, res, next) {
  res.render('index');
});

Can someone please tell what is wrong here.

Leave a Comment

techhipbettruvabetnorabahisbahis forumutaraftarium24eduedueduseduseduseduedusedueduedu