【发布时间】:2016-09-16 08:03:00
【问题描述】:
我是 node.js 的初学者,我正在为我的 Web 应用程序使用 hapi 框架。在那我使用车把作为模板。当我配置服务器视图时,我收到类型错误。
'use strict';
const hapi = require('hapi');
const server = new hapi.Server();
const inert = new require('inert');
server.connection({
host: '127.0.0.1',
port: 8080,
});
//Starting server
server.start((error) => {
if(error){
throw error;
}
console.log("Server running" + server);
});
server.register(inert, () => {
console.log("hhh");
server.views({
engines: {
html: require('handlebars')
},
path: 'views',
layoutPath: 'views/layout',
layout: 'default',
partialsPath: 'views/partials'
//helpersPath: 'views/helpers',
});
});
我收到此错误:
TypeError: server.views is not a function
at server.register (/home/developer/Workspace/kravein-test/app/backend/server.js:22:9)
at process.nextTick (/home/developer/Workspace/kravein-test/node_modules/hoek/lib/index.js:854:22)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:577:11)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
at bootstrap_node.js:467:3
我正在使用 hapi 15.0.3。谢谢
【问题讨论】:
标签: javascript node.js hapijs