11

Using Command Line Arguments in Node.js

 3 years ago
source link: https://www.devdungeon.com/content/using-command-line-arguments-nodejs
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Using Command Line Arguments in Node.js

Submitted by NanoDano on Sat, 08/01/2015 - 19:56

These code snippets demonstrate how to access command line arguments for a Node.js program.

// Access specific arguments
console.log(process.argv[0]);
console.log(process.argv[1]);

// Iterate through all arguments
process.argv.forEach(function(val, index, array) {
  console.log(index + ': ' + val);
});

Advertisement


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK