(NodeJS)错误:找不到模块'html'

时间:2019-07-23 10:21:52

标签: javascript html node.js

在我的nodeJS完成功能之后,我正在尝试呈现index.html文件。但这告诉我他找不到模块HTML

这是nodeJS代码

var http = require ('http');
var fs = require('fs');
var port = 3000;
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var jsFile = require('./src/GS1DigitalLinkToolkit');
var app = express();
var compressFunction = require('./compression');
var uncompressFunction = require('./decompression');
var router = express.Router();
var gs = require('./gs1');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));

app.use(express.static(__dirname + '/files'));
app.set('views', __dirname + '/files');
app.set('view engine', 'html');

app.get('/', function(req,res){
  res.sendFile('index.html', {root: path.join(__dirname, './files')})
})

app.post('/compression', function(req,resp){ //Post Response
  var compression = req.body.compression;
  var compressedLink = compressFunction.compressedDigitalLink(compression);
  resp.render('files/index', {compressedDigitalLink :compressedLink});
});

这是层次结构: enter image description here

我读到我需要添加:

app.set('views',__dirname +'/ files');

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

但是我仍然有这个错误: enter image description here

我还应该添加什么?

谢谢您的帮助

0 个答案:

没有答案