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.


$ 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 :)


Popular posts from this blog

How to simulate slow connection (developer proxy in Node.js)

How to use NPM packages from private repositories on bitbucket