1

I can debug normal node applications by node-inspector and node-debug command.

How to debug my bower resolver?

I have only one idea: write another node app and require my bower resolver in it and use methods programmaticaly. Actually, I think that the correct way is to debug it on bower install.

So, how?

Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87

1 Answers1

1

I don't have time to write a well-tested answer, but you can try your luck with the following methods:

  • use console.log, console.dir in resolver's code (you should see output when doing bower install although it depends how exactly the resolvers are invoked by bower)
  • write a unit test (see example) and debug it in isolation
  • use a command like node-debug $(which bower) install (or node --debug-brk /path/to/node_modules/bower/bin/bower + node_inspector in separate console tab) to do integrated debugging; remember to put debugger statement in your JS file in the resolver's methods to pause in node-inspector at proper stage of execution
Community
  • 1
  • 1
jakub.g
  • 38,512
  • 12
  • 92
  • 130
  • console.log is not the way to debug the code. Yes people can use it but it is not really well way :) I have unit tests and I can debug my code through it, this is not the way too. And yes I tried to debug my code with node-debug. It deesn't work =/ – Sharikov Vladislav Jul 23 '16 at 16:10
  • What do you mean by "doesn't work" exactly? you have blank Chrome DevTools screen? – jakub.g Jul 23 '16 at 16:16
  • 1
    I am not right. Shame on me but I forgot about the `debugger` keyword. Main problem was (thats why I said it doesn't work) I couldn't find my resolver source files so I couldn't put breakpoint. Now I put debugger in the code and node-debug stopped on it. Works like a charm. – Sharikov Vladislav Jul 23 '16 at 16:20
  • Cool :) basically with every globally installed node program like `grunt`, `gulp` etc you'd do the same, you need to find the main entry point with `which grunt` etc. and start `node-debug` with it as a parameter. – jakub.g Jul 23 '16 at 16:28