I'm trying to understand if I can debug a stand alone .js file which doesn't interact with browser. Is there any way to just load it and debug or I will be forced to encapsulate it into html file?
Environment is Windows, no browser objects are required.
To debug a stand-alone script, my first thought would be to use Rhino debugger -- have you tried that? I've also heard about v8 debug, but I have no experience with it yet.
Related
What is the industry standard or professional process of finding out where the actual line number in the source code of your rendered page is happening?
I have used browser debug tools and it of course shows you the error, but the line number is not the same for the source code file that is being served up. I know that usually server side scripts are making the file longer than it really is and etc.
I usually just do a find for functions or code near the error and can eventually find it, but is there a better way?
The simplest way is to ensure that most of your JS is written in non-templated .js files, rather than inline <script> blocks in your templated html.
I develop with Visual Studio.net 2013, which will stop at breakpoints and break on server and client side errors.
If you aren't developing with a tool like VisualStudio that has a built in debugger with breakpoints, etc., the built in developer tools in Chrome and IE are awesome (IMHO). Since Javascript runs clientside, you'll need to debug it using the browser. If you don't like the built in developer tools, you can also try Fiddler and Firebug.
I am not experienced in developing web apps with NetBeans.
I created an HTML5 project with existing sources (some HTML, JS and CSS files), the import seems to be OK, but I didn't manage to debug JavaScript code, because the "Debug project", "Debug file" and "Debug test file" menu items are always disabled.
What have I missed?
PS.: I downloaded a fresh version in November 2013.
HTML5 project is always debugging and running at the same time if you run it in any browser with NetBeans connector (check the browser switcher in toolbar). So once you run project/file, if some breakpoint should be hit, it will be. Therefore debug action is not enabled for HTML5 project, because it is the same as Run action.
Basically it means you can debug JS in Chrome with NetBeans Connector, Embedded browser in IDE, Chrome on Android, Safari on iOS...
I also ran into issues when trying to debug JavaScript in a PHP project. I was using Chrome as my browser and had confirmed that the Netbeans Connector extension was installed and working in Chrome.
I could debug PHP without any issues. I could create a separate HTML5/JavaScript project and debug JavaScript without any problem. However, when I tried to set breakpoints on JavaScript code that was embedded in tags within the PHP file, I would get the little 'broken' breakpoints that everyone else references. When I selected the option to debug project, I could debug the PHP code, but the JavaScript breakpoints were never hit.
The change that I made that finally (for me) caused the JavaScript breakpoints to be hit so I could step through code using the Netbeans debugger was to remove the Javascript from the file containing the PHP/HTML code and place the JavaScript in a separate file that only contained JavaScript via a within the PHP file. Magically, I could debug both JavaScript and PHP within the same debugging session without any extra setup.
Of course, one alternative is to use the debugger within the browser, such as Chrome developer tools, but I really wanted to be able to debug everything from within the same Netbeans environment. Works like a charm now.
Never used the JavaScript debugger myself but you find here a tutorial if it has to be the Netbeans debugger. As an alternative I can recommend the JavaScript debugger from Firebug.
Use the Chrome debugger once the page is loaded in the browser.
When you end up solving cross browser compatibility you'll have to use particular browser console/debugger implementation (which may not be fancy). Before that enjoy in ChromeDevTools or FireBug :)
Ok, this is some question...well, I haven't seeing in any other place a question like this one...
I need to debug a javascript file through Eclipse (Helios)...but, that is not all, the javascript file is called by a third party application (C/C++) that runs (Mozilla) SpiderMonkey to execute the js file.
I need, someway to conect Eclipse to this application and get the debug symbols. Or, something like that...
Anyone see something like this before? Have an advice?
[EDITED]
Scenario:
The application (consoleApp.exe) runs the javascript engine SpiderMonkey embedded.
I need to, from Eclipse IDE, attach the application process and debug the current javascript source that SM is running.
Tks!
[THANKS!!!]
For anyone who gives a thought/comment/idea to answer this question. I figured out what i have to do, but, it will be difficult. I need to ask to modify the application core to expose the debug information coming from SpiderMonkey and JSD. And write an Eclipse plugin (or modify Pistol, maybe) to
comply with i want to do. Again, thanks to everyone.
You can try Firbug or Firefox web developer tools under Tools option.
In Eclipse:
JavaScript Development Tools (JSDT) - Eclipse.org
www.eclipse.org/webtools/jsdt/
I am not very sure about this but you can have a look into this
OR
The Google Chrome Developer Tools for Java allow debugging using Chrome.
It looks like Piston does exactly what you are asking for in your original question, although you cannot use it to debug your executable directly as in your clarification. Unfortunately, it also looks like it is hard to set up.
Doesnt Eclipse have something similar to .Net's 'Attach to process' under debug options? That way, you can easily debug your client side using your firebug, and whenever a server script is executed, your eclipse will debug it as if it were executed from there.
I want to debug javascript in my .cshtml file and adding "debugger;" is troublesome.
Is there a better way of debugging javascript in .cshtml files being debugged under VS2010?
The best way for me has always been to just open the site in a browser and use the browser's development tools. All of them allow setting breakpoints, watch variables etc. these days.
I am writing in javascript for windows (and also in wsf using javascript and vbscript) a desktop script not for internet and not using any explorer.
I need tool for debugging (free one).
Does someone can recommend on one ?
Thanks
I'm assuming you are creating WSH scripts based on your description. In order to debug WSH JavaScripts, start your script with wscript.exe /d path to WSH file after that, whenever an exception is going to occur, you are going to be presented with a choice to debug the script with Visual Studio or Microsoft Script Debugger (free). If you just want to step through the code start your script with wscript.exe /d /x path to WSH file this will cause an exception right at the begging of your script execution.
More information here
Aptana Studio is a great Eclipse extension and can also debug Javascript
I've heard Firebug Lite could do this? That's probably not what you're looking for still.
From the question, it sounds like you are trying to make an AJAX app that perhaps loads from local javascript + HTML.
That said, if it is OK to use Firefox as the web client, you might try Firebug. It is an excellent javascript debugger. It lets you do usual step / breakpoint things, inspect variables, and display the current page as a DOM model to help see what your jQuery (or Prototype, in my case) queries will find.