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 ? 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 How to Show the Line which Cause the Error in Node.js ? Debugging is a critical part of software development. When an error occurs in a Node.js application, understanding exactly where it happened is essential for diagnosing and fixing the problem. Node.js provides several ways to pinpoint the line of code that caused an error. This article explores thes 4 min read Pass function and arguments from node.js to Python Prerequisites: How to run python scripts in node.js using the child_process module. In this article, we are going to learn how to pass functions and arguments from node.js to Python using child_process. Although Node.js is one of the most widely used web development frameworks, it lacks machine lear 4 min read How to Get the Path of Current Script using Node.js ? In Node JS, getting the path of the current script is useful for file operations, logging, and configuration. It allows you to access related files or directories reliably, regardless of where your Node.js process was started.ApproachTo get the path of the present script in node.js we will be using 2 min read What is stacktrace and how to print in node.js ? Stacktrace in Node is a report that displays the error along with the path or sequence of execution. It provides the sequence of function calls or operations that led to an error in a program. It helps to debug the issues by providing the path of execution.A Stack trace is displayed automatically by 3 min read How to Open Node.js Command Prompt ? Node.js enables the execution of JavaScript code outside a web browser. It is not a framework or a programming language, but rather a backend JavaScript runtime environment that allows scripts to be executed outside the browser. You can download Node.js from the web by visiting the link "Download No 2 min read Like