Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 722
Tal Gvili Avatar asked Apr 03 '16 18:04

Tal Gvili


1 Answers

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.

like image 160
Nagama Inamdar Avatar answered Sep 27 '22 23:09

Nagama Inamdar