Parse User Input through Node.js process argv for Flags

Share this video with your friends

Send Tweet

When you run Node.js, you'll have access to the process object. If you console log it out you'll see that it has quite a bit of information stored on it. Dig through there and check it out!

We will focus on the argv property. This property is an array that has the path to node and our script as the first and second values. When we pass in arguments or flags to our script, argv include the values that we will pass.

We will see how we can check for flags and run conditional logic based on the flags that are passed.