Languages
[Edit]
EN

Node.js - get arguments from command line

0 points
Created by:
Aran-Busby
592

In this article, we would like to show you how to get arguments from command line in Node.js.

Quick solution:

 

1. Practical example using process.argv

Edit

In this example, we use process.argv to get the arguments from command line. The arguments should be specified in the running command.

1.1 Run the app without arguments:

Output:

1.2 Run the app with arguments:

Output:

2. Skip the first two arguments

Edit

In this example, we present how to skip the first two arguments of the process.argv when you don't need them.

2.1 Run the app without arguments:

Output:

2.2 Run the app with arguments:

Output:

References

Edit

Alternative titles

  1. Node.js - parse command line arguments
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join