I am using Microsoft Visual Studio to build a mobile app using Cordova. The JavaScript console logs in VS are somehow persistent over different debugging sessions, which often causes confusion to myself. How do I make it automatically clear VS console logs every time I build?
I am using Visual Studio 2015.
This may be what you want to use:
console.clear();
https://msdn.microsoft.com/en-us/library/hh696634.aspx
Related
As the title indicates, I am writing in Visual Studio (community 2019) a Blazor WebAssembly app that contains JavaScript (and TypeScript). Sometimes, when I make code changes to the js and then run under the debugger, the old version of the js code is still being used by Chrome (v16.6.1 if memory serves) as shown using their devtools. I have searched endlessly for a way to force the changed file to load, but no luck so far. Any suggestions? Thanks. Steve
I come from developing in ASP.NET MVC/C# using Visual Studio. In this stack, debugging is very thorough and straightforward. You create a project, code, set breakpoints, and hit F5 to step through them.
What are my options with Node.js? Specifically using Visual Studio Code? I've tried setting up a debug config file but it has mixed results, and seems to be a lot more error-prone than debugging in C#/Visual Studio. Is there any way to get debugging features streamlined in Node the same way I am used to in Visual Studio with C#? I know JS is interpreted rather than compiled...
Update: I have tried clicking the debug button and setting up a launch.json file. However, this usually leads me into errors. For example, I have set up launch.json to my app's entry point and my app uses an MVC pattern. When I launch the app, the debugger stops at the breakpoint before I even visit the controller endpoint, whereas in Visual Studio with C#, the debugger would listen and when I visit the endpoint, it would then stop at the breakpoint so that I could step through. The Visual Studio Code/Node debugger seems to want to step through all breakpoints before the endpoints are even triggered. I have also tried the Nodejs Tools extension for Visual Studio 2015 Community, which produced Microsoft Typescript errors. It just deosn't seem very straightforward.
have you tried using Chrome? When in Chrome press F12 to get the Developers Tools displayed, then you have the output console and can see the source and set break points.
Here are some options for debugging node outside of visual studios:
How do I debug Node.js applications?
Now for backend, I would recommend using Postman for Chrome:
https://www.getpostman.com/
It will consume any API and allow you to see if the information you have entered is correct. A huge time saver if you want to check the routes of an API, the parameters being sent to the API, and data being sent back.
It would seem as most people don't know how to use or know that it can even be used to debug in visual studios.
I am trying to get an Aurelia project working in Visual Studio. I followed the steps outlined here and it builds and runs correctly.
This process has me using a "Web Site Project" (Not a Web Application Project). This is so that the tsconfig.json file can be used.
While it runs just fine, I cannot find a way to debug. (Meaning set a breakpoint and have the the app break and let me step through the code.)
Is Typescript/JavaScript debugging not supported with Web Site Projects? (I am using VS 2015).
If is supported for Web Site Projects, then I would love a suggestion on how to enable it or troubleshoot it.
Debugging in VS in general is only supported with Internet Explorer. If you tried an other browser (edge?), that may be your problem.
Is there any debugger like there is in Visual Studio,for example in C#, I can follow every step of the program and find out how the code works, which function does it call first or what value does a certain integer has after loop? Thanks
Yes, there is. It's in Visual Studio!
When you launch a your web application from Visual Studio in Internet Explorer you can set breakpoints in your JavaScript code and use the debugger from Visual Studio just as you would with C#.
Make sure that you have debugging scripts enabled in Internet Explorer.
You can find more info here in the documentation Client-Side Script Debugging at MSDN.
Currently I am debugging my JavaScript using Firebug for Firefox. Is there anyway to debug javascript in Visual Studio 2010? The JavaScript isn't part of any Visual Studio project, it's just a .js file that will be linked to a static HTML page (it's to debug school assignments).
I did try searching and the results weren't any more recent than around a year ago. I'm hoping something has changed or there is a better workflow than notepad++ for HTML/JavaScript and Firebug for debugging.
Use the JavaScript debugger keyword in IE.
function onClickRow(detailUrl) {
debugger;
}
When run your page in IE, a debug window will pop up, then select Visual Studio 11.
To use debug in Internet Explorer, you need perform these steps:
enable script debugging in IE (go to Internet options->advanced->browsing and uncheck 'Disable script debugging')
select view->external script debugger->break on next statement
When next javascript statement will be reached, IE will show standard windows debugger selection dialog, when you can select instance of visual studio.
Update:
With visual studio you can attach to browser process(e.g. iexplore.exe) and then debug
This question gets a lot of views so for the sake of completeness I just wanted to mention that I've been using Chrome Developer Tools for a while now. It's been working great for me and is what I recommend now when people ask me this same question.
Yes, but only in IE. Basically just create a web-page project and hit run. It'll launch IE in debugger mode.
disable option from Internet Options like here : http://www.mayanksrivastava.com/2010/02/debugging-java-script-in-visual-studio.html
If you installed VS 2012 and then uninstalled it, you may need to Re-Install Visual Studio 2010.
Error you may get when trying to debug JavaScript:
---------------------------
Microsoft Visual Studio
---------------------------
Unable to attach to the crashing process. The correct version of pdm.dll is not registered. Repair your Visual Studio 2010 installation, or run 'regsvr32.exe "%CommonProgramFiles%\Microsoft Shared\VS7Debug\pdm.dll"'.
---------------------------
OK
---------------------------
If you want to try giving it a shot in IE, I posted about using the js debugger here:
jQuery/Ajax content not appearing/loading in Explorer