Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

365
Visualizações
Express js render : TypeError: this.engine is not a function

I am getting TypeError: this.engine is not a function. I don`t know why I am getting this error. Can anyone please help me to solve this issue.

My server file:

var express = require('express');

var path = require('path');

var app = express();

//configure app
app.set('view engine', 'html');
app.set('views', path.join(__dirname, 'views'));

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


app.listen(3000, function() {
    console.log('Ready on port 1337');
});

And my HTML file:

<!DOCTYPE html>
<html>

<head>

</head>

<body>
    <div>Hello Express</div>
</body>

</html>

I get the error

enter image description here

My package.json:

{
    "name": "app",
    "version": "1.0.0",
    "main": "index.html",
    "directories": {
        "test": "test"
    },
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": "mehadi",
    "license": "UNLICENSED",
    "dependencies": {
        "express": "4.13.0",
        "html": "^1.0.0"
    },
    "repository": {
        "type": "git",
        "url": "(github.com/mehadi07/Random.git)"
    },
    "devDependencies": {},
    "description": ""
}

I installed the html engine via

npm install --save html
about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

The html package you've installed is unrelated to Express. So it's not surprising that if you tell Express to use it, it fails.

If you're looking to serve static HTML files, see this question's answers, and the Express documentation. The simplest way is just

app.use(express.static('views'));
about 4 years ago · Santiago Trujillo Relatório

0

html package is not a template engine that can be used with Express. Instead it is a HTML pretty printer CLI utility.

Please see Using template engines with Express for a list of template engines that works fine with Express.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda