如何獲取配置Angular和VSCode以便我的斷點工作?如何使用VSCode調試Angular?
42
A
回答
64
- 安裝Chrome Debugger Extension
- 創建
launch.json
(內.vscode文件夾) - 用我
launch.json
(見下文) - 創建
tasks.json
(內.vscode文件夾) - 用我
tasks.json
(見下) - 按CTRL + SHIFT + 乙
- 按F5
launch.json for angular/cli >= 1.3
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach Chrome",
"type": "chrome",
"request": "attach",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceRoot}"
},
{
"name": "Launch Chrome (Test)",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceRoot}"
},
{
"name": "Launch Chrome (E2E)",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceRoot}/protractor.conf.js"]
}
]
}
tasks.json for angular/cli >= 1.3
{
"version": "2.0.0",
"tasks": [
{
"identifier": "ng serve",
"type": "npm",
"script": "start",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"identifier": "ng test",
"type": "npm",
"script": "test",
"problemMatcher": [],
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
測試與角5/CLI 1.5.5
- 安裝Chrome Debugger Extension
- 創建
launch.json
- 用我
launch.json
(見下文) - 啓動NG直播開發服務器(
ng serve
) - 按F5
launch.json for angular/cli >= 1.0.0-beta.32
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:4200",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"userDataDir": "${workspaceRoot}/.vscode/chrome",
"runtimeArgs": [
"--disable-session-crashed-bubble"
]
},
{
"name": "Attach Chrome",
"type": "chrome",
"request": "attach",
"url": "http://localhost:4200",
"port": 9222,
"webRoot": "${workspaceRoot}",
"sourceMaps": true
}
]
}
launch.json for angular/cli < 1.0.0-beta.32
{
"version": "0.2.0",
"configurations": [
{
"name": "Lunch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceRoot}/src/app",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./~/*": "${workspaceRoot}/node_modules/*",
"webpack:///./src/*": "${workspaceRoot}/src/*"
},
"userDataDir": "${workspaceRoot}/.vscode/chrome",
"runtimeArgs": [
"--disable-session-crashed-bubble"
]
},
{
"name": "Attach Chrome",
"type": "chrome",
"request": "attach",
"url": "http://localhost:4200",
"port": 9222,
"webRoot": "${workspaceRoot}/src/app",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./~/*": "${workspaceRoot}/node_modules/*",
"webpack:///./src/*": "${workspaceRoot}/src/*"
}
}
]
}
與角2.4.8
0
這裏測試是有點輕解決方案,具有角工作2+(我用角4)
如果運行MEAN堆棧,還添加了Express Server的設置。
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Angular Client",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"runtimeArgs": [
"--user-data-dir",
"--remote-debugging-port=9222"
],
"sourceMaps": true,
"trace": true,
"webRoot": "${workspaceRoot}/client/",
"userDataDir": "${workspaceRoot}/.vscode/chrome"
},
{
"type": "node",
"request": "launch",
"name": "Launch Express Server",
"program": "${workspaceRoot}/server/bin/www",
"outFiles": [
"${workspaceRoot}/out/**/*.js"
]
}
]
}
+0
您可以使用此配置在角度的同時調試/斷點您的服務器端代碼嗎? – Mika571
15
看起來像VS Code團隊正在存儲調試配方。
https://github.com/Microsoft/vscode-recipes/tree/master/Angular-CLI
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome with ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceRoot}"
},
{
"name": "Launch Chrome with ng test",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceRoot}"
},
{
"name": "Launch ng e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceRoot}/protractor.conf.js"]
}
]
}
相關問題
- 1. [VSCode]如何在mac中使用sudo調試VSCode中的節點?
- 2. 使用Delve調試GO VSCode
- 3. 使用Angular 4在vscode中調試Asp.Net核心應用程序
- 4. 如何使用VSCode調試器來調試Gunicorn工作進程?
- 5. 用vscode調試電子。 runtimeExecutable
- 6. 如何在VSCode中調試coffeescript?
- 7. 調試打字稿上VSCode
- 8. 如何使用.Net Core和VSCode在調試模式下執行測試?
- 9. 如何使用Visual Studio調試Angular 4單元測試代碼
- 10. 如何在Angular中啓用PouchDB調試
- 11. 使用node.js使用chrome調試VSCode中的Typescript
- 12. 如何在VSCode中調試使用PM2運行的Node.js應用程序?
- 13. 使用VSCode調試電子僞造應用程序
- 14. 使用Inspector協議的VSCode調試節點應用程序
- 15. 如何使用Visual Studio 2017調試Angular 2
- 16. VSCode - 如何使用啓動配置調試啓動自己的調試器的節點程序?
- 17. Autodesk Maya使用Visual Studio代碼進行調試(VSCode)
- 18. 使用vscode調試npm腳本的正確方法是什麼?
- 19. 使用VSCode調試自定義Yeoman生成器
- 20. 調試Angular應用程序
- 21. 在vscode中調試grommet-cli sample-app
- 22. VSCode調試器條件斷點
- 23. 將grunt附加到VSCODE調試器
- 24. vscode工作目錄時調試python
- 25. 如何使用angular和jqlite測試event.target.hasClass()?
- 26. 如何調試C++在mac上的VSCode中工作?
- 27. 如何在Visual Studio代碼(VSCode)中調試Cucumber?
- 28. 如何在vscode中調試打字稿和反應文件(.tsx)
- 29. VSCode - 如何設置調試工作目錄
- 30. 如何調試已安裝的VSCode擴展?
你是什麼意思?他們怎麼不工作? – TylerH
@TylerH,它應該是一個指導它是如何工作的。它沒有修改launch.json不起作用。 – Asesjix