调试&使用 Visual Studio Code 运行 Angular2 Typescript? [英] Debug & Run Angular2 Typescript with Visual Studio Code?
问题描述
调试&使用 Visual Studio Code 运行 Angular2 Typescript?
我正在尝试使用 VS 代码调试 Angular2 打字稿应用程序
Debug & Run Angular2 Typescript with Visual Studio Code?
I am trying to debug Angular2 typescript application with VS code https://angular.io/guide/quickstart
Can anyone please share steps to debug & run from VS code?
After lot of research, I found these steps-
Before you begin, make sure you have latest version of VS code. You can verify latest version – Help > Check For Updates or About.
Install extension called 'Debugger for Chrome'. Once install complete, restart VS code.
Go to Debug window, open launch.json using Chrome.
In Launch.json configuration section, use below config
{ "name": "Launch localhost with sourcemaps", "type": "chrome", "request": "launch", "url": "http://localhost:3000/Welcome", "sourceMaps": true, "webRoot": "${workspaceRoot}" }
In tsconfig.json, make sure you have "sourceMap": true
This completes your debug environment settings. Now, before you start debugging, make sure all your existing Chrome.exe instances are closed. Verify from Task Manager OR Use DOS command ‘killall chrome’
Run your project, using npm start command and Chrome as default browser.
Once application is run successfully, you will receive port number. Copy URL from chrome browser and paste into url section above. (NOTE: If you are using routing in your application then url would like above otherwise it will be ending index.html etc)
Now, place breakpoints wherever you want in your typescript files.
Again, go to debug window in VS code, and hit Run. Your tab/instance connected to debugger will looks like below.
这篇关于调试&使用 Visual Studio Code 运行 Angular2 Typescript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!