如何在visual studio代码launch.json文件中运行npm脚本

时间:2017-06-23 16:19:34

标签: javascript node.js npm visual-studio-code

我正在尝试在Visual Studio代码的launch.json文件中运行以下npm脚本:

nodemon src/shim-host/index.js --exec babel-node --babel-preset-es2015

到目前为止我在launch.json文件中的尝试:

"program": "nodemon src/shim-host/index.js --exec babel-node --babel-preset-es2015",

但是,我收到错误"Attribute 'program' is not absolute'"

有人可以帮忙吗?

提前致谢!

1 个答案:

答案 0 :(得分:3)

program属性是你的代码,nodemon应该是runtimeExecutable。

来自Inspect service workers with Chrome的示例:

{
    "name": "Launch server.js via nodemon",
    "type": "node",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "runtimeExecutable": "nodemon",
    "runtimeArgs": [
        "--debug=5858"
    ],
    "program": "${workspaceRoot}/server.js",
    "restart": true,
    "port": 5858,
    "console": "integratedTerminal",
    "internalConsoleOptions": "neverOpen"
}