Node.js 提示模块不遵守选项

Node.js prompt module not honoring options

我有一段相对简单的 node.js 代码,这是我第一次尝试使用提示模块。看看:

const schema = {
  properties : {
    username : {
      description : "Please enter username", type : "string", required : true,
      validator: /^[a-zA-Z0-9]+$/, warning : "must be comprised of letters and numbers only"
    }
  }
};
prompt.start();
prompt.get(schema, function (inError, inResult) {
  if (!inError) {
    userInfo.username = inResult.username;
  }
});

看,不太难。问题是当我 运行 它时,输出是这样的:

"username: "

...而应该是这样...

"Please enter username: "

它不尊重描述选项,我正在用头敲桌子试图找出原因。这可能是我的一些愚蠢的程序员把戏,但我只是没有看到它。我试过只传递属性本身,而不是作为外部模式对象的一部分,但这没有区别。更糟糕的是它似乎是在向验证者致敬,所以它看起来像是一个错误?

有人有什么想法吗?谢谢!

您应该将 description 替换为 message。这不是记录在案的更改。

username : {
      message : "Please enter username", type : "string", required : true,
      validator: /^[a-zA-Z0-9]+$/, warning : "must be comprised of letters and numbers only"
    }