【发布时间】:2017-08-29 16:36:28
【问题描述】:
我正在尝试使用 VS Code 运行一个简单的 CRUD 节点模块。
模块的简化版本如下所示:
const getAll = () => {
// return all elements
}
const saveElement = element => {
// takes an object and goes through it and saves it
}
const removeElement = id => {
// deletes the element with the passed id or returns false
}
const readElement = id => {
// returns the element from the data
}
我使用 yargs 来获取应用程序的参数,但我也使用命令来调用每个方法,就像这样
node app.js remove --id="123456789"
VS Code 中的launch.json 如下所示:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Test Remove",
"program": "${workspaceRoot}/app.js",
"args": [
"--id='123456789'"
]
}
]
}
我一直无法做的是将特定的remove、add、list、read 命令添加到调试器中以检查这些方法,因为没有这些,应用程序仅使用参数和它返回一个我添加的日志,表明传递的命令未被识别。
我查看了 VS Code 文档,但没有找到与我正在尝试做的事情相关的任何内容。
【问题讨论】:
标签: node.js debugging command visual-studio-code