From the course: Node.js Essential Training

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Handling argument variables with process.argv

Handling argument variables with process.argv - Node.js Tutorial

From the course: Node.js Essential Training

Handling argument variables with process.argv

- [Instructor] One important object that's available to us globally is the process object. So it can be accessed from absolutely anywhere, and it contains functionality that allows us to interact with information about the current process instance. With the process object, we can get environment information, read environment variables, communicate with the terminal, and we can exit the current process. So it gives us a way to work with that current process instance. So one of the things that we can do with the process object is collect information from the terminal. So this information is stored in the process.argv array. So check this out. We're going to get rid of the code that was here before and replace it with a console log to figure out what is available in this process.argv value. Now, we want to make sure that we're navigated to the right file here, and we can run node global. This will then return to us this…

Contents