2017-10-06 37 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" 
    } 
}