Build a Command Line Application with Node.js

Build a Command Line Application with Node.js

Learn how to build command line applications using Node.js

Julian Knight

Great post, thanks for the info. Very helpful.

m_wojo

This is a great article. Thank you!
Thought it may be helpful to share that we just published a guide with more info about using Node.js on Windows. http://docs.microsoft.com/w…
We’re recommending the new Windows Subsystem for Linux v2 (WSL2) for Node.js development work due to the nice integration with Linux tools and servers, as well as the VS Code Remote-WSL extension which lets you run your VS Code UI in Windows but your Node apps on a Linux server that are totally integrated. I’ve just started looking into Node.js command line apps using the WSL2 set up… so thanks again for the article!

David Neal

Sweet! Thanks for tip, @m_wojo!

Ahmed EL-Metwally

thank you bro, your article helped me

Mohan Raj Vivek

Very useful article. Learned new things about how to add colors and authentication to cli-apps.

What tool to use to generate the hand-writing type flow chart?

David Neal

The flow chart was drawn on an iPad using one of my favorite apps, Sketches Pro by Tayasui. Glad you found the post useful!

David Neal

Glad to hear it!

Julian Knight

I do lots of open source development on Windows natively using Node.js and Node-RED. No need to get into the complexity of WSL & it encourages you to write cross-platform code including command-line scripts. I would much rather write a node.js script and call it from npm than I would write separate bash, cmd, PS scripts. And only 1 language to learn.

Oddly, my main use for WSL is to SSH into remote shells - it seems to be vastly quicker to use WSL to do that than to use the native Windows SSH client. Weird but true.

Shounak Mukherjee

Hello David,
This article has been really helpful. I have been trying to develop similar tool but having some issues. Can I follow it up with you please?

Boris

Beautiful explanation. Thank you! Never built a CLI before, this post got me running my own CLI in minutes!

Rafael G. Blanes

Thanks for this post. I’be been wondering about how to do this with node long time ago.

Prathy

Super article, it helped me a lot. I have one query, how can we maintain state of application with cli application? Consider an example where I have expose different functionality as command and one command create an object, and rest of commands operate on that object. Here when i hit second command I didn’t get that object.

Davidhu127

It’s cool that JavaScript can make CLI apps just like Bash and Python, with the help of Node.js