re: Developing your first CLI (command line interface) tool using NodeJS VIEW POST


El sueño de la razón produce monstruos —Francisco José de Goya y Lucientes

To get the command line utility I would need to install NodeJS, and explode my OS with a ton of unknown, untested, and insecure NPM packages? Is this a joke?

There are many languages very suitable to produce command line utilities: c, rust, even go to some extent. Using NodeJS for that is basically the last thing you’d do if you want your utility to be used by people.


As a polyglot myself, I do admit that NodeJS is not a perfect choice to build a CLI tool. The critical point lies in empowerment.

There are many front-end developers who may not be as familiar as you with languages like c, c++, rust, or go. But due to their rich experience in JavaScript, they can master NodeJS quicker than any other language. And this post can help them build a CLI tool with less effort.

And supposing you are going to publish an NPM package which you want to bundle a binary in, will you choose to write that binary in another language, or just use NodeJS?

In addition, commander.js has no external dependencies and is well tested. Its github repo has 13,000+ stars, and it has been downloaded 70M+ times in the past month. The other packages used in this post are all optional.


will you choose to write that binary in another language, or just use NodeJS?

I was not aware of NodeJS being able to produce binaries. In any case, if this is about something to be used inside NodeJS ecosystem only, it probably is fine, but as soon as we are talking about CLI tools in general, I expect it to be of kilobytes in the size. Even Go is able to produce relatively small binaries.

$ ls -la `which fzf`
-rwxr-xr-x 1 am am 2490723 jun 10  2018 /home/am/.fzf/bin/fzf
code of conduct - report abuse