3
votes

I have created a jhipster module (yeoman generator) following steps from [1] and I would have loved to be able to debug the node.js code from the generator at the moment when it is being used in a jhipster app. I found tool at [2] but it acts as if the code from the generator does not get to be run.

Detailed explanation:

I have created the jhipster module generator-jhipster-entity-replacer.

I created a project jhipster-test-proj in whom I invoke the generator.

yo jhipster-entity-replacer

This is the moment where I would like to see that my breakpoints from generator-jhipster-entity-replacer node.js code are toggled, but nothing happens.

May someone help me with detailed explanation?

I might have been a little blury in explanations due to the fact that I have moreover a stronger Java background then Javascript related one. If someone can help me, but needs more information, please ask.

[1] https://jhipster.github.io/modules/creating-a-module/

[2] https://github.com/node-inspector/node-inspector

1
I'm also curious about techniques to debug the generator. But this link is a starting point : yeoman.io/authoring/debugging.html - Pierre Besson

1 Answers

0
votes

Update:

I' ve managed to debug with the command from Pierre Besson's link:

node --debug <path to yo cli.js> <generator> [arguments]

in my case:

 node --debug C:\Users\PowerUser\AppData\Local\Yarn\config\global\node_modules\yo\lib\cli.js jhipster-entity-replacer

Even though, I do not recommend this approach. It is a command line debugger with a limited set of instructions, but is still a doable thing.

What i recommend, is this one, a DevTools version for node.js: https://github.com/node-inspector/node-inspector

I've ran it with the command:

node-debug C:\Users\PowerUser\AppData\Local\Yarn\config\global\node_modules\yo\lib\cli.js jhipster-entity-replacer

Note:

  • I had to manually delete .yo-rc.json from my generator because otherwise it would not have worked (i had an error like "Just found a .yo-rc.json in a parent directory.", and then it would stop).

  • when running yo <generator behind, it is actually running node <path-to-cli.js> <generator> [this is why debugging with node inspector with that command is ok]