我希望能够使用Visual Studio Code调试Angular2应用程序.
这是我的环境:
使用angular-cli创建一个新项目:
ng new test-VSC-debug
cd test-VSC-debug
Run Code Online (Sandbox Code Playgroud)
然后我打开VSC并加载项目: File/open folder
我点击debug的标志,我configure launch.json的选择chrome.它生成以下文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
然后我通过运行启动angular2项目:
ng serve …Run Code Online (Sandbox Code Playgroud) google-chrome-devtools visual-studio-code angular-cli angular