【问题标题】:In hapijs 'property register of undefined' is comming在 hapijs 中,“未定义的财产登记”即将到来
【发布时间】:2018-04-04 18:44:27
【问题描述】:

以下是我在运行 hapi.js 服务器时使用的包
包是:

package.json

"dependencies": {
    "handlebars": "^4.0.11",                                           
    // dependencies i have taken 

    "hapi": "^16.6.2",
    "inert": "^4.2.1",
    "vision": "^5.3.2"
  }
}

App.js

const Hapi = require('hapi');
//Init server
const server = new Hapi.Server();

//Add connection
server.connection({
    port:15000,
    host:'localhost'
});

//Home route

server.route({
    method:'GET',
    path:'/',
    handler:function(request,reply){
       reply('Hello world');
    }
});

//Static routes
server.register({
    register: require('inert')
},function (err) {
    if(err){
        throw err;

    }
});


//Vision templates
server.register(require('vision'),function (err) {
   if(err){
       throw err;
   }
   server.views({
       engines:{
           html:require('handlebars')
       },
       path:__dirname+'/views'
   });
});

// Start Server
server.start(function(err)  {
    if(err){
        throw err;
    }

    console.log('Server started at:'+ server.info.uri);
});

这是一个来自 hapi.js 的程序,它是一个 javascript 框架。 我在 node.js 的视觉和车把中获得未定义的属性“注册”。

错误是'未定义的属性寄存器'

【问题讨论】:

  • @Xufox 请看我的代码
  • 你能回答@Xufox

标签: javascript hapijs


【解决方案1】:

在我看来,您在使用 Hapi 16 时正在以 Hapi 17 方式注册您的插件...

你应该至少给出完整的错误信息

【讨论】:

  • 已经知道了,我错过了vision的版本,应该是4系列的。
猜你喜欢
  • 2015-05-11
  • 1970-01-01
  • 2020-10-18
  • 1970-01-01
  • 1970-01-01
  • 2011-03-13
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
相关资源
最近更新 更多