How to print command line arguments passed to the script in Node.js ?
In Node.js if you want to print the command line arguments then we can access the argv property on the process object. process.argv returns an array that contains the absolute path of Node.js js executable as the first argument, the absolute file path of the running script, and the command line arguments as the rest of the element. We can pass the command line arguments to our script using the following command on the command line.
node file-name.js argument1 argument2 argumentN
Steps to print command-line arguments:
Step 1: Install Node.js if Node.js is not installed on your machine.
Step 2: Create an app.js file in the particular directory.
Project Structure: After following the steps your project structure will look like the following.
Run app.js file using below command:
node app.js geeks for geeks