How to print command line arguments passed to the script in Node.js ? Last Updated : 10 Oct, 2021 Comments Improve Suggest changes Like Article Like Report Node.js is an open-source and cross-platform runtime environment built on Chrome's V8 engine that enables us to use JavaScript outside the browser. Node.js helps us to use build server-side applications using JavaScript. 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. Syntax: 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. app.js const args = process.argv; console.log(args); args.forEach((e, idx) => { // The process.argv array contains // Node.js executable absolute // path as first element if (idx === 0) { console.log(`Exec path: ${e}`); } // Absolute file path is the second element // of process.argv array else if (idx === 1) { console.log(`File Path: ${e}`); } // Rest of the elements are the command // line arguments the we pass else { console.log(`Argument ${idx - 1}: ${e}`); } }); Run app.js file using below command: node app.js geeks for geeks Output: Comment More infoAdvertise with us Next Article How to print command line arguments passed to the script in Node.js ? S shivamsingh00141 Follow Improve Article Tags : Web Technologies Node.js Node.js-process-module NodeJS-Questions Similar Reads How to Parse Command Line Arguments in Node ? Command-line arguments, in the context of a command-line interface (CLI), are text strings that provide extra information to a program when it is executed.In Nodejs, these arguments are accessible through an array known as argv (arguments values), where the shell passes all received command-line arg 3 min read How to Print Second Command line Argument in shell? Command line arguments are the parameters we pass to a command or script when we run it from the terminal. These arguments are passed as strings and can be accessed within your program to perform various operations. How to Print Second Command Line Argument in Shell?The shell stores the command line 5 min read How to Read Command Line Arguments in Node ? Command-line arguments (CLI) consist of text strings utilized to provide extra information to a program during its execution via the command line interface of an operating system. Node facilitates the retrieval of these arguments through the global object, specifically the process object. ApproachTo 2 min read Sending Command Line Arguments to NPM Script In the sector of NodeJS development, NPM (Node Package Manager) scripts are a effective tool for automating numerous tasks like strolling exams, building the mission, or starting a improvement server. However, there are times while you need to bypass arguments to these scripts to customize their beh 3 min read Bash Script - How to use Command Line Arguments In this article, let us see about Command Line Arguments usage in Bash script. Arguments are inputs that are necessary to process the flow. Instead of getting input from a shell program or assigning it to the program, the arguments are passed in the execution part. Positional Parameters Command-line 4 min read Like