DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Frameworks
  4. How to Debug an Angular Application With Chrome and VS Code

How to Debug an Angular Application With Chrome and VS Code

You can debug an Angular application with Chrome and VS Code. Of course, you can also configure Chrome to attach directly.

Fabian Gosebrink user avatar by
Fabian Gosebrink
·
Jan. 03, 17 · Tutorial
Like (2)
Save
Tweet
Share
18.34K Views

Join the DZone community and get the full member experience.

Join For Free

In this post, I want to show you how to debug an Angular application with Chrome and VS Code.

First of all, you need to install the extension in VS Code.

You can find it here or search in the extensions tab for the plugin directly:

Image title


After installing, you probably have to enable the plugin and restart VS Code, but in the end you will see your folder structure like normal. Then, head over to the debug tab and press the button for creating you an new configuration and select the “Chrome” environment.

Image title


After doing this, the extension created a new folder (if you do not have it already) called “.vscode” with a “launch.json” in it, initially looking like this:

{ "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}" } ] }

Our folder structure tells us that the files are served from the root.

So, the "webRoot”: “${workspaceRoot}”” setting is good to go for us. We will open a new Chrome instance but it needs an existing running server. So, if you use something like lite-server, you can easily type “lite-server” at the root of your web application or place it in your NPM command chain in the “NPM Start” command. This is what I did.

Before we go, we need to adjust the URLs where the server is running and the URL where the Chrome instance is starting.

So, replace the port in the config file with the port from your lite-server. In my case, that's “3000.” 

Then, start the lite server and just hit “play.”

Image title

Image title



Chrome starts and you can debug your page in VS Code. Of course, you can also configure Chrome to attach directly. See here for examples.

Virtual screening Web application Debug (command) Visual Studio Code AngularJS

Published at DZone with permission of Fabian Gosebrink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Explainer: Building High Performing Data Product Platform
  • Data Mesh vs. Data Fabric: A Tale of Two New Data Paradigms
  • Type Variance in Java and Kotlin
  • Playwright vs. Cypress: The King Is Dead, Long Live the King?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: