Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

364
Views
Express js render: TypeError: this.engine no es una función

Recibo TypeError: this.engine no es una función. No sé por qué estoy recibiendo este error. ¿Alguien puede ayudarme a resolver este problema?

Mi archivo de servidor:

 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'); });

Y mi archivo HTML:

 <!DOCTYPE html> <html> <head> </head> <body> <div>Hello Express</div> </body> </html>

me sale el error

ingrese la descripción de la imagen aquí

Mi paquete.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": "" }

Instalé el motor html a través de

npm instalar --guardar html
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

El paquete html que ha instalado no está relacionado con Express. Así que no es sorprendente que si le dices a Express que lo use, falla.

Si busca servir archivos HTML estáticos, consulte las respuestas a esta pregunta y la documentación de Express . La forma más sencilla es simplemente

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

0

El paquete html no es un motor de plantillas que se pueda usar con Express. En su lugar, es una bonita utilidad CLI de impresora HTML .

Consulte Uso de motores de plantillas con Express para obtener una lista de motores de plantillas que funcionan bien con Express.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!