在网上看都是这么写:
app.register('.md’, {
compile: function(str, options){
var html = markdown.makeHtml(str);
return function(locals){
return html.replace(/{([^}]+)}/g, function(_, name){
return locals[name];
});
};
}
});
但是运行后出现这个异常:
TypeError: Object function app(req, res){ app.handle(req, res); } has no method
‘register’
at Object.<anonymous> (C:\Users\xiangdefei\myblog\app.js:31:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions…js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
是不是新版本的express的register函数没有了?我的express是3.x的。