0

这是我的 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 throw new Error(msgs.join(' ') || '未知错误'); ^

错误:无效的注册选项{“reporters”[1]:{“console”:[{“module”:“good-squeeze”,“name”:“Squeeze”,“args”:[{“log”:“* ",

有什么解决办法吗?

4

1 回答 1

0

要注册此处给出的解决方案

{
  "plugin": {
    "register": "good",
    "options": {
      "reporters": {
        "console": [
          {
            "module": "good-squeeze",
            "name": "Squeeze",
            "args": [
              {
                "log": "*",
                "response": "*"
              }
            ]
          },
          {
            "module": "good-console"
          },
          "stdout"
        ]
      }
    }
  }
}
于 2017-09-05T12:09:31.767 回答