Some time ago I accidentally discovered a neat feature of Node.js, which seems undocumented (at least I could not find anything about it in the docs). If you have some npm project in a directory, say /tmp/some-npm-project
, and it has the main
property in package.json
set to some Node.js script, say bin.js
, then saying just node /tmp/some-npm-project
runs /tmp/some-npm-project/bin.js
. It turns out to be quite useful if you have a directory full of various Node.js CLI utilities, each occupying its own directory, with its own package.json
, especially considering shell autocompletion.
And that’s it for today!