Issue with remote debugging in WebStorm + Nodemon - javascript

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

Related

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

Node js server auto restart [duplicate]

I am running a node.js application in Windows and I want to make it automatically restart if there is an unhandled exception in the code which causes the application to stop.
I have done some research and I found that a combination "Forever" and "Nodemon" can achieve this goal.
I installed both packages globally on my Windows 10 Device.
npm install forever -g
npm install -g nodemon
I tried using the following command to launch my app:
forever start nodemon --exitcrash app.js
However, I get the following error: "nodemon does not exist"
If try just running "nodemon" the application starts which indicates the Nodemon package is installed however, this will not allow the app to restart after a crash.
Am I doing something wrong? Most advice I find online is only relevant to Linux systems.
If you are already using forever, then you can get rid of nodemon. Instead you can use a combination of forever and cluster module. Simply fork the worker in case of exceptions, and it makes your app more scalable too!
If still nodemon is preferable, maybe try installing it globally using the -g flag
Forever and nodemon achieve 2 completely different objectives
nodemon is used to run your application in development mode, where you are frequently changing code, and need to restart the server .It will not restart your application in case of a crash. more about that later
Forever, on the other hand, is for making your application run as a daemon in production. And auto restart if you have uncaught exceptions.
Historically people have used Forever stand alone, or with upstart scripts, running as a linux service one of the most famous being upstart
Current norm is to use PM2

Local Server Auto Refresh of create-react-app is not working in my VM

Local Server Auto Refresh of create-react-app is not working in my Virtual Machine: When I update my code, the server is not auto updating.
I'm using Ubuntu as OS and VSCode to write code and the VSCode terminal to run the app locally.
The command to local startup:
npm start
I created an .env and add CHOKIDAR_USEPOLLING=true to it.
Why? This ensures that the next time of run npm start, the watcher uses the polling mode, as necessary inside a VM.
Got this from here:
Development server of create-react-app does not auto refresh
And up the answer.

Issue related to running of New React App

I installed Nodejs(v 10.16.0 LTS) and then using Windows Powershell I run following commands
npx create-react-app my-app
cd my-app
npm start
The actual problem I am facing is that if PowerShell window is opened in the background, then my code works properly. But when I close PowerShell and reload Browser Tab, the error occurs which say
This site can’t be reached
localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall.
Kindly help me to figure out this issue. Thanks
When you close PowerShell window you terminate your React app as well, it has to stay opened. Running npm start kicks off local server with your app running. If you want to have possibility to have application running with terminal closed you can use libs like https://www.npmjs.com/package/forever, but I do not recommend that- it's easy to forget you have one app instance running already :)
When you run the command npm start, this is the expected behaviour. This command spawns a new npm instance in the directory from where you have executed it and directs it to start a server. The catch here is that the server runs as an attached process with PowerShell, by default and it is bound to terminate once you close the PowerShell window.
To manually detach a process from the terminal, we use an & after the command on a UNIX-based system (Linux, MacOS etc.) something like npm start &.In case of PowerShell, you can make use of a built-in function called Start-Process like this -
Start-Process -NoNewWindow npm start
If you'd like to read more about it, you can refer a blog post here - https://ariefbayu.xyz/run-background-command-in-powershell-8ea86436684e

Debugging node js in Webstorm when running from gulp

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.

Categories

Resources