2017-10-06 67 views
0

我确定这是超级简单,但我似乎无法得到调试通过启动通过NPM vscode模板。我有一个非常简单的hello世界,用npm脚本来运行应用程序。VSCode调试器不会附加启动通过NPM

如果我运行Launch Program(即只使用节点的配置)一切完美,但如果我用Launch via NPM我得到

/Users/luke/.nvm/versions/node/v6.5.0/bin/NPM --debug-BRK = 3837运行脚本runit

[email protected] runit /用户/卢克/源极/操场/ JS /你好世界

节点index.js

hello world

并没有发生断点。 (我也尝试过有和没有"protocol":"legacy"

我做错了什么,所有在线的例子都表明这应该justworkTM。

的package.json

{ 
    "name": "hello-world", 
    "version": "1.0.0", 
    "scripts": { 
    "runit": "node index.js" 
    } 
} 

launch.json:

{ 
    "version": "0.2.0", 
    "configurations": [ 
    { 
     "type": "node", 
     "request": "launch", 
     "name": "Launch via NPM", 
     "runtimeExecutable": "npm", 
     "protocol":"legacy", 
     "runtimeArgs": [ 
      "run-script", 
      "runit" 
     ] 
    }, 
    { 
     "type": "node", 
     "request": "launch", 
     "name": "Launch Program", 
     "program": "${workspaceFolder}/index.js" 
    } 
    ] 
} 

index.js

console.log('hello world');//with a breakpoint set here 

回答

1

好,我的工作了......通过

启动NPM要求您添加一些额外的参数到实际的NPM脚本中:

{ 
    "name": "hello-world", 
    "version": "1.0.0", 
    "scripts": { 
    "runit": "node --nolazy --debug-brk=5858 index.js" 
    } 
} 
相关问题