Is there a reason to build a command line application in Node.js? It doesn't really seem like Node is the right tool for the job...
How to write a command line application in Node.js
21–30 of 56 posts
Re: How to write a command line application in Node.js
#22Earlier quoted context omitted.
If you're doing crazy heavy processing or something, it's not the right tool. But you wouldn't do that in JS. You'd shell out or call something native. Node is best used managing parallel streams of stuff. Perhaps surprisingly, a command line application is a great example of that. I would much rather build a nontrivial command line app in node than in anything else. Try it, you'll see.
There are tons of better options to choose from. If you're not making a web UI, literally any choice is better than Javascript, unless that is the only language you know.
People don't use node for the Javascript. They use it for the modules, and node is the glue that coheres them (and does an admirable job at that).
When you're comparing writing a CLI app in node to writing it in something else, it's a world of difference, and that difference is npm. With good modules, writing a CLI app has little to do with Javascript -- you're more specifying config and flow by passing some options and streams around, and you're done.
Re: How to write a command line application in Node.js
#23The number one reason to write CLI apps in node is npm. npm gets package management right, preferring local dependencies to global ones - this means no worrying about what version of a library a user has in their global environment. You also get to bring node's parallel io-centric patterns to your scripting. Need to download a bunch of files from a remote host, process them, and write them to disk? Go for it. But tak…
Re: How to write a command line application in Node.js
#24Earlier quoted context omitted.
Yes. If a person already knows JavaScript well, then it will be easier for them to write a CLI app/utility/script in JS than it would be to write a shell script. Another reason to write in JS would be to gain code reuse. If the person has a web app that uses node, then they can share code between the web and CLI applications.
> Another reason to write in JS would be to gain code reuse. > If the person has a web app that uses node, then they can > share code between the web and CLI applications. I often see this argument presented for just about any server side js. I often wonder about actual real world reuse though.
I wrote a database specifically for web browsers and someone case along and write a relatively small pull request and it now works in node / on the server / with a http api - http://pouchdb.com
Re: How to write a command line application in Node.js
#25Re: How to write a command line application in Node.js
#26The number one reason to write CLI apps in node is npm. npm gets package management right, preferring local dependencies to global ones - this means no worrying about what version of a library a user has in their global environment. You also get to bring node's parallel io-centric patterns to your scripting. Need to download a bunch of files from a remote host, process them, and write them to disk? Go for it. But tak…
alternatively: maven managed to get dependency management right about 5 years ago.
Re: How to write a command line application in Node.js
#27Earlier quoted context omitted.
alternatively: maven managed to get dependency management right about 5 years ago.
Hahaha really? Have you seen a pom file on a real project its about 10 pages with plugins galore.
Re: How to write a command line application in Node.js
#28Earlier quoted context omitted.
alternatively: maven managed to get dependency management right about 5 years ago.
Hahaha really? Have you seen a pom file on a real project its about 10 pages with plugins galore.