How do I debug server and client simultaneously in WebStorm? - javascript

I have a node.js app that runs a server and sends index.html. The index.html interacts with the server.
I want to debug the complete app, but when I debug the app, WebStorm only debugs the server.
Is this even possible in WebStorm? If not, are there other tools that can do this?

In the Node.js run configuration, Browser/Live Edit tab, specify the URL of your server, tick both After launch and with JavaScript debugger checkboxes - client-side debugger will be launched once you start your node server with this configuration, so that you will be able to debug both simultaneously, using a single run configuration.
See also https://www.jetbrains.com/help/webstorm/debugging-javascript-in-chrome.html#debugging_js_on_external_web_server for some hints on debugging client-side code run in browser

Related

sending console JS commands to an Electron app

I'm looking to automate an existing Electron app. It gives access to the Developer Tools, so I could just paste Javascript code into the console, but there must be a way to do this remotely, ideally using Node or from the Terminal?
I've seen this option for running Chrome : --remote-debugging-port=9222 ... that hints at a solution but I can't seem to get closer.
If you launch your Electron app with --remote-debugging-port=9222 then you will enable remote debugging via Chrome DevTools protocol. You can use a Chrome developer tools instance as a client, or use one of the clients here: https://github.com/ChromeDevTools/awesome-chrome-devtools#chrome-devtools-protocol
The debuggable Chrome instance will be running on localhost:9222. Which means as long as you are trying to debug from the same machine you are fine. However if you want to debug from a remote machine you need some additional setup.
Setup an SSH tunnel on the source machine:
ssh -L 0.0.0.0:9223:localhost:9222 localhost -N
This will accept incoming traffic on the 9223 port and route it to Chrome remote debugging.
Then on your client machine use the address: source-machine-ip:9223 to access the remote debugging.
Note: This may not work on Windows without additional SSH setup as SSH is not prepackaged with Windows.

Apache Cordova: running cordova run browser without launching browser app

I have Apache Cordova app on my dedicated server. Access it via console. But when I run
'cordova run browser'
I get error
Static file server running # http://localhost:8000/index.html
CTRL + C to shut down
Error executing "google-chrome --user-data-dir=/tmp/temp_chrome_user_data_dir_for_cordova http://localhost:8000/index.html": [21075:21075:0423/054416:ERROR:browser_main_loop.cc(271)] Gtk: cannot open display:
And thus I cannot start test server with my app. How I can avoid automatic browser start?
Thanx
I know it's been a while but what I did to avoid opening browser was editing the file under './platforms/browser/cordova/run' and changing the line:
return cordovaServe.launchBrowser({target: args.target, url: projectUrl});
to:
return cordovaServe;

Run node.js app remotely on WebStorm?

I have node.js installed on Vagrant and WebStorm access to a project on shared folder via VirtualBox.
Can I run node.js application on WebStorm and see the output on WebStorm (Terminal or SSH)? At the moment I have to keep switching to Putty to run it to see the output, its gets quite tiring.
Running Node.js applications remotely is not currently supported, please follow WEB-6136 for updates.
Debugging remote applications is possible (using Node.js Remote Debug run configuration - see https://confluence.jetbrains.com/display/WI/Running+and+debugging+Node.js+application#RunninganddebuggingNode.jsapplication-DebuggingNode.jsappthatrunsremotely). But you can't see the remote process output in WebStorm console, as Stdout of it is not accessible via debug protocol WebStorm uses for remote debugging. Related feature request: WEB-17013
This feature is available through ssh on Webstorm 2017.1
Scroll down to Configuring a remote Node.js interpreter on a host accessible through SSH connection in the link below:
https://www.jetbrains.com/help/webstorm/configuring-node-js-interpreters.html

Running node-webkit as node.js app

Is there any way to make node.js be host process for a node-webkit application?
I'm using Intellij IDEA for node.js development, and it have best debugger for node atm. But node-webkit presents its own nw.exe process, which can't be debugged by normal node.js environment. Other debug options (chrome devtools) don't match in effeciency with IDEA debug.
IDEA present some kind of nw debug support, but its very raw and works with many glitches and not works for many things.
So I want develop node-webkit app which starts under control of node.js process, like appjs was doing.
You could do that if you manage to launch nw.exe in debug mode using child_process.exec and make sure the line "Debugger listening on port [nnnnn]" is written to stderr, because according to https://youtrack.jetbrains.com/issue/WEB-1919#comment=27-556387
IDE parses it and can understand that a new debug session should be initialized and what debug port is.
That would be enough BUT the problem is:
child_process.exec will not return stderr until the child process ends and it does not provide a way to pipe it to the node.js host.
node-webkit only provide a --remote-debugging-port option to specify the port to open a devtools debugger; there's no option to start in debug mode (something like --debug or --debug-brk)

IDEA Failed to load resource

I want to debug my html + javascript site in IDEA and Chrome browser.
When I press 'debug' in console i got:
Failed to load resource file:///C:/js/angular.min.js
As I undestand, I need to set root path of my web site in properties. But where this option?
Such urls (site root-relative, the ones starting with slash) can't be properly resolved when opening file locally (using file:// protocol) - the browser will search for these files in your system root (C:/). You need using remote javascript debug configuration (access your html using the web server url rather than local path) to make this work. See http://wiki.jetbrains.net/intellij/Debugging_JavaScript_with_IntelliJ_IDEA#Remote_debugging for more information on remote javascript debugging in Idea
Note that Idea 12 supports so-called built-in webserver (http://confluence.jetbrains.com/display/WI/built-in+web+server), so you can test your code without installing a web server.
Instead of accessing from local file system try to access your html + javascript application from a web server by putting those appication files in web server.
Install XAMPP or WAMP in your system and copy your application into the htdocs folder to run that application locally.Also edit the files using IDEA from there.So,you can parallely edit using IEDA and run using XAMPP.
http://www.apachefriends.org/f/viewtopic.php?t=14173.

Categories

Resources