Debugging node js in Webstorm when running from gulp - javascript

I'm fairly new to this, but I really tried my best looking for up for answers.
I used yeoman to generate an application. (used 'angular fullstack' - https://github.com/angular-fullstack/generator-angular-fullstack)
It has a gulpfile.babel.js config file, which runs nodemon.
What I'm trying to do is to make the gulp serve nodemon instance to hit the Webstorm breakpoints I have.
What I've tried so far :
-- Regular debugging. (trivial..) But it seems node sends excpections when he meet ECMA6 syntax. (Still.. I rather run the gulp instance than run it from webstorm.)
-- Using --debug
-- Using 'remote debug' in webstorm.
-- Setting up node inspector in gulp task and set him to listen 5353
-- Using --debug-brk and debug on port 5353 (for example)
I could really appreciate it if someone could help me.
This guy here says Webstorm can't handle this case, but it's weird, you can debug remote servers but you can't debug gulp nodemon server instance?
Debugging node app in WebStorm when run from gulp

Assuming you are using Node.js. It provides node inspector to debug the server side files on the chrome browser itself, with similar experience given in browser debugging.
Here is the reference link to set up the node inspector.
Following are the steps to set node inspector.
1) Install node inspector with command
npm install -g node-inspector
2) Start node inspector
You can start it from any directory
node-inspector
As a result, you will receive a url to debug in browser
3) Restart the node server in debug mode
change the directory to the server folder of your project
cd /path/to/your/project/directory/nodejs/server
node --debug server
4) once the server is started in debug mode successfully, copy the url received in above result and open it in Chrome browser. There you can see all the server side files of Node.js on the source section of the debugger, where you can apply the breakpoints on the server javscript files those have been written.

Related

How do I get NPM commands to run properly in Eclipse?

I have a usable workflow that I want to make better. I'm building a JS library, and the way I am executing smoke tests on code is by using webpack to package the library and write it to a file that is included in an HTML file for viewing the effects of the code.
To do this, I make changes to the file in Eclipse, save it, then I must leave Leave eclipse and go to Terminal to run "npm run buildInbrowser" to execute "webpack --config inbrowser.config.js".
The configuration works perfect with regards to webpack, the configuration, and the npm setup, but when I try to configure eclipse to run those commands, it brings up an error: "env: node: No such file or directory" I've attached screenshots of my launch NPM configuration.
My system is MacOSX Catalina using Nodeclipse, npm v9.3.1 and node 16.18.0.
Again, there is no issue with me running these commands in terminal, but they won't run through node. This makes me think it's something simple that I overlooked.
As nitind pointed out, I had incorrect syntax on the PATH variable for eclipse, which was causing the problem. Also noted is that Eclipse did not populate my path variable by default, so i did have to manually enter it in. See the screen shot for the fix.

Session Error While Using WebdriverIO with Appium on Android Device

I cloned the repo https://github.com/Schveitzer/webdriverio-appium-cucumber-boilerplate and tried to run the tests.
I consistently get the following error.
2022-06-16T22:51:13.157Z ERROR #wdio/runner: Error: Failed to create session.
Unable to connect to "http://localhost:4723/", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
Steps:
Clone the repo
Download the latest version of the demo app which Android-NativeDemoApp-0.4.0.apk. The one in the repo does not work.
Update the capabilities.
Yarn Install/Yarn Run
I made some changes. However, was not able to resolve the issue. Any suggestions to resolve the issue?
From the error, it seems that appium server is not running. One reason could be that the repo has an old version of packages and you might have installed the latest version of appium.
One thing you could try is to remove the this line from the config file and try the below.
Start the appium server using the command appium on terminal
Run your tests and see if it works
Otherwise, you have to upgrade all the packages in the repo. but this also means you may have to change something in the code.
Your appium server is likely not running, from package.json I can see that the appium-service that is supposed to get it up is missing. You have two options:
install the #wdio/appium-service package, and appium should run automatically or
start the appium server yourself, either from the terminal with appium -a 127.0.0.1 -p 4723 or launch the appium desktop app

Issue with remote debugging in WebStorm + Nodemon

I am using Nodemon to speed up my development so it restarts my app when I do some changes.
As WebStorm debug is not working with Nodemon in standard way (%NODE_DEBUG% or --debug-brk does not trigger debugger properly), I found the way where I run nodemon --debug-brk and remote debugging session in WebStorm.
The issue which I got is that every time when nodemon restarts my app it hangs on (the app) until I will restart my remote debug and then it enters my entry JS file and then I can 'continue' and it works then. It is annoying and I have no idea how to set it up properly.
Is it either better way to set up Nodemon+WebStorm or somehow set WebStorm in a way when it will not loose connection to that debug session?
As WebStorm debug is not working with Nodemon in standard way
(%NODE_DEBUG% or --debug-brk does not trigger debugger properly)
WebStorm does allow debugging applications run with Nodemon using either Node.js
or NPM run configurations
The issue which I got is that every time when nodemon restarts my app
it hangs on (the app) until I will restart my remote debug and then it
enters my entry JS file and then I can 'continue' and it works then.
Known issue, WEB-25672

Automate Protractor / Selenium / Webdriver command

How can i start my localhost server with node app.js, run webdriver-manager start, and protractor conf.js in one command.
Each of these commands take place in a different folder.
I want to streamline this process.
I have a written an alias that executes each command in their respective folders.
Problem is, each of these commands launch a server, and the terminal enters non-canonical mode which causes an issue.
I have tried adding & to the end of each command, but this did not work.
Solve it via a task management tool like grunt or gulp.
Here is the list of plugins that might be useful in your case:
grunt-protractor-runner
grunt-contrib-connect
grunt-contrib-watch
See also:
Testing With AngularJS Part 5: Protractor and Grunt
Integrating Protractor with Yeoman via Grunt

WebStorm, using Node Supervisor (so do not have to restart after each code change)?

I'm using WebStorm as my node IDE and love it overall but I haven't been able to figure out how to use node supervisor when running node through WebStorm. Has anyone gotten this to work? I think I'm just not sure how to pass through the supervisor argument so that it uses this when starting the node file.
Install supervisor globally:
npm install -g supervisor
WebStorm/IntelliJ run configuration for non-debug:
Name: supervisor app.js
Path to node: <same>
Node Parameters: /usr/local/lib/node_modules/supervisor/lib/cli-wrapper.js --exec /usr/local/bin/node --no-restart-on exit
Working directory: <same>
Path to Node App JS File: app.js
These paths are for Mac OS X 10.8 so you'll have to replace the above paths with paths on your machine. Next, you'll be able to run this in debug mode but it doesn't step through the code.
For debugging you can either use the remote debugger or just have a different run target for debugging without using supervisor.
It is amazing that I reach the goal by simply changing the path of node to the path of supervisor. So, I think this will also work for you.
Ps. I'm using WebStorm version 6.0.1.

Categories

Resources