Convenient Node Debugger Run by NPM

If you read installation instruction of node-inspector you would think that the only way to use it is to install it globally. Here I want to suggest embedding it in the project.

Installation:

$ npm install -g node-inspector
$ npm install node-inspector --devDependencies

After doing that, you need to add "debug" line to "scripts" part of package.json

"scripts": {  
    "start": "node app.js",  
    "debug": "./node\_modules/.bin/node-debug app.js" }

And run it:

$ node-debug app.js
$ npm run debug

It has downsides, that is obvious, but in my opinion it has also big advantages.

New person on the team does not need to follow long readme of global modules to install - and remember how all of them are supposed to be run. Another advantage is ignoring all the problems that you may have with sudo (needing it to install anything global). In my opinion it is also simpler and more convenient. All commands can be scripts starting with $ npm run *.

Of course it has some downsides as well. In case of many projects you would need to install and update the same module in every project. "NPM run debug" is yet another thing that must be stated in readme or being part of team culture as known part of every project to be most useful, and the last one: anyone using IDE will still need to install it even knowing they are not going to ever use it.

If you like this idea, give it a try :)



Share on Hacker News
Share on LinkedIn


← Home


Want to learn more?

Sign up to get a digest of my articles and interesting links via email every month.

* indicates required

Please select all the ways you would like to hear from Krzysztof Kula:

You can unsubscribe at any time by clicking the link in the footer of my emails.

I use Mailchimp as a marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.