It’s quite common when running an application to want to pass arguments to the program to define how it should run when executed. This is no different then with Node.js. To accomplish this I like to use one of two ways:
- Reading the JavaScript array node js process.argv and manually parsing the variables
- Using an npm library such as minimist that helps simplify and (in my opinion) parses them into a nice JavaScript variable
Let’s take a look at both ways.