我有一个带有 Express 的 Node 服务器。尽管我的代码看起来像这样并且在我看来应该是正确的,但我收到了无法找到模块“html”错误:
app.set('views', path.join(__dirname, 'build/views'));
app.use(favicon(path.join(__dirname, "build/favicon.ico")));
app.use('/scripts', express.static(path.join(__dirname, 'node_modules')));
app.use(express.static(path.join(__dirname, 'build')));
app.get('/', function(req, res){
res.render('index.html');
});
最佳答案
您必须为 HTML
设置引擎
将此代码包含在您的主文件中
var engines = require('consolidate');
app.engine('html', engines.mustache);
app.set('view engine', 'html');
关于node.js - Express NodeJS 找不到模块 'html',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39506787/