胶水+好的控制台无法正常工作[Hapi.js]

时间:2017-07-22 17:15:47

标签: node.js hapi.js hapi-good

这是我的config.json代码:

{
    "connections": [
        {
            "port": 3000
        }
    ],
    "registrations": [
        {
            "plugin": "./plugins/db"
        },
        {
            "plugin": "good",
            "options": {
                "reporters": {
                    "console": [
                        {
                            "module": "good-squeeze",
                            "name": "Squeeze",
                            "args": [
                                {
                                    "log": "*",
                                    "response": "*"
                                }
                            ]
                        },
                        {
                            "module": "good-console"
                        },
                        "stdout"
                    ]
                }
            }
        },
        {
            "plugin": "./routes/bookmarks"
        },
        {
            "plugin": "blipp"
        }
    ]
}

和server.js:

'use strict';

const Hapi = require('hapi');
const Glue = require('glue');

const manifest = require('./config.json');

const options = {
    relativeTo: __dirname
}

Glue.compose(manifest, options, (err, server) => {
    if (err) {
        throw err
    }

    server.start((err) => {
        if (err) {
            throw err
        }

        console.log(`Server is running at ${server.info.uri}`)
    });
})

我得到的错误:

  

/home/master/Documents/Hapi/starter/node_modules/hoek/lib/index.js:736       抛出新错误(msgs.join('')||'未知错误');       ^

     

错误:无效的注册选项{"记者" [1]:{       " console":[         {           "模块":"良好的挤压",           "名称":"挤压",           " args":[             {               " log":" *",

对此有何解决方案?

1 个答案:

答案 0 :(得分:0)

注册the solution given here

{
  "plugin": {
    "register": "good",
    "options": {
      "reporters": {
        "console": [
          {
            "module": "good-squeeze",
            "name": "Squeeze",
            "args": [
              {
                "log": "*",
                "response": "*"
              }
            ]
          },
          {
            "module": "good-console"
          },
          "stdout"
        ]
      }
    }
  }
}