我有一个package.json
的节点应用程序,如下所示:
{
"name": "myexpressapp",
"version": "0.0.99",
"scripts": {
"start": "node ./bin/www" },
//etc
}
并在app.js
我有
console.log ("Running version: "+process.env.npm_package_version);
当我在命令提示符下运行npm start
时,会记录
正在运行的版本:0.0.99
当我在VS Code中开始(按 F5 )时记录
正在运行的版本:未定义
我需要对launch.json
在VS Code中启动应用程序做出哪些更改,就像我在命令提示符下输入npm start
一样?
答案 0 :(得分:0)
我现在可以使用以下launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM#3",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"start"
],
"port": 5858,
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program#1",
"program": "app.js",
"cwd": "${workspaceRoot}"
}
]
}