0
我是node.js的初學者我爲我的web應用程序使用hapi框架。在那我使用模板的把手。當我配置服務器視圖時,我得到了類型錯誤。TypeError:server.views不是hapi.js中的函數
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
我使用高致病性禽流感15.0.3:
'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',
});
});
我得到這個錯誤。由於
感謝Huw Davies。有用。我在這裏看到了https://futurestud.io/tutorials/how-to-create-a-dynamic-handlebars-layout-template-in-hapijs上的教程。但在這個他們從未使用視覺插件。還有一些其他教程,我也檢查他們從來沒有使用它。它基於hapi版本? – Sivabalan
我不太明白'基於hapi版本'的意思嗎? @Sivabalan –
要在hapi 15.0.3中使用server.views(),是否應該包含視覺? – Sivabalan