-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript debugger not working #1890
Comments
If I remove, "preLaunchTask": "npm: start" from launch.json, then from the terminal I run my web app using: npm start Now if I hit F5 to run the debugger it will hit my breakpoint. So I would like to be able to trigger the npm script to run the app and the browser to launch with the debugger working. Not sure what is brokem, or the correct way to set the launch.json config for debugging a web application. Here is a demo app project to use: https://github.com/rajinder-yadav/demo-debug |
You haven't shared your launch.json, but it looks like debugging never starts in VS Code because it's waiting for the |
Hello my launch.json is in the original message at the top. In the past this use to work, infact in the past I didn't even need to create my own launch,json file. I think this bug should be re-opened and worked on, as it use to work before out of the box. |
OK if you start with no launch.json the debugger will show the following in the debug panel, so click on the highlighted option. You will then see the following, select, "Node.js" You will then see, select the top option, "Run Script: start" This will start the debugger and your breakpoint will never get hit. FYI: The debugger should be smart enough to detect the "npm" scipts in package.json file and it should select, "npm start" as default and then be able to detect if it's a web app (ionic, angular, vue, react). If it's a web app launch the browser when debugging. If not, treate it as a node.js server app and debug likewise. The debugger should just work out of the box and provide the best developer experience. You can check the "dependencies" for an idea what type of app is getting launched in package,json The following is a ionic / anguar web app so launch a browser with the debugger automatically. "dependencies": {
"@angular/animations": "^17.0.2",
"@angular/common": "^17.0.2",
"@angular/compiler": "^17.0.2",
"@angular/core": "^17.0.2",
"@angular/forms": "^17.0.2",
"@angular/platform-browser": "^17.0.2",
"@angular/platform-browser-dynamic": "^17.0.2",
..
"@ionic/angular": "^7.5.0", |
This is definitely a bug, why should there be a difference between me, having to type, "npm start" from a terminal and then run the debugger by hitting F5 for things to work, compaed to VSCode doing both? |
Sorry, I meant that you hadn't shared your tasks.json where the If you debug the "run script: start", you will be debugging the Node.js server that is compiling and serving your Angular project. In that case your breakpoints will not be bound, because Angular code is not running in this server. You instead want to debug the browser. Here's a tutorial from our docs on an Angular setup in VS Code: https://code.visualstudio.com/docs/nodejs/angular-tutorial though that doesn't cover setting up a prelaunch task which was your original issue. To do that ideally, the Angular folks would provide a problem matcher in their extension, but they don't do this today angular/vscode-ng-language-service#625
I thought about that in the past,but opted not to it. There are an infinite number of frontend frameworks and ways to launch frontend frameworks. I'm not interested in maintaining a list of matchers for them and being responsible for updating matchers as CLIs and their usages change. While users occasionally get confused when they try to debug their npm script instead of their web app, this is not terribly common and in my view not enough to justify the maintenance burden of trying to 'magic' over it. |
I agree with you about the maintanance headace, I reazlied that as soon as I submitted my request (my bad). As for the angular article, this is what I am already doing. The part in the article where it says: "Press F5 or the green arrow to launch the debugger and open a new browser instance." It stop working like this, nothing is running or gets executed like the npm "start" script. So a browser opens at "http://localhost:4200" like this The work-around I found is I need to first go to the terminal and type, "npm start", then press F5 and it will work and the breakpoint is immediately triggered. However that last step, before I didn't need to do this. Also if I add the following to the launch.json config "preLaunchTask": "npm: start" it starts the build but like you said the debugger is not debugging angular anymore? So can this be fixed, or maybe provide a default (drop down) option like, "run npm start and open browser" ??? I don't think it obvious to new dev how to get the debugger working, it just seem broken. Ideally hitting F5 should build and run either a node.js server app, or as node.js web app if package.json is found to exist. Then you just need to check for one file and provide maybe two default options.
Added comment for your understanding, how you word these default options is up to you. I would just like option 2) to kick of "npm start" and open the web browser to begun debugging. |
Type: Bug
Ionic Angular application builds and run when debugger is started, but breakpoint is never triggered.
The other bug is chrome fails to launch and open at url.
debug launch.json
Refresh browser several times, see console log print everytime, breakpoint never triggered.
Extension version: 2023.11.1317
VS Code version: Code - Insiders 1.85.0-insider (05cd2640ec8a106a4ee99cb38e6ee34fbec04f11, 2023-11-21T05:34:53.583Z)
OS version: Linux x64 6.6.2-1-default
Modes:
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: