【发布时间】:2021-09-24 07:20:15
【问题描述】:
我正在尝试学习 Node.js,目前我正在研究如何在不同文件之间加载/导出模块和链接代码。我遇到了我编写的这个函数,它似乎没有在我的 VS 代码终端中显示预期的输出:
这是我编写的主要处理程序:
yargs.command({
command: "Read",
describe: "Reading the note",
builder: {
title: {
describe: "Note title",
demandOption: true,
type: "string",
},
body: {
describe: "Note body",
demandOption: true,
type: "string",
},
},
handler(argv) {
notesUtility.readNotes(argv.title);
},
});
这是我应该导出到处理程序的模块:
const readNotes = function (title) {
const notes = loadNotes();
const note = function (note) {
if (note.title === title) {
console.log(chalk.inverse(note.title));
console.log(note.body);
} else {
console.log(chalk.red.inverse("Notes not found!"));
}
};
};
除了这个之外,所有其他模块都非常好并且在我的终端中显示了预期的输出,我尝试调试它,但即使调试器似乎也无法获取模块的这一部分。就像是看不见一样。
有人知道发生了什么吗?我希望这个问题对任何阅读它的人都有意义。
【问题讨论】:
标签: javascript node.js visual-studio-code event-handling