NodeJS command line parameter framework

by Selim @Selim

Hi all, I'm looking for volunteers to develop in NodeJS a framework to manage parameters for a "product". The parameters comes to an application in different way :

  1. Command line options (short and long : -h or --help)
  2. Environment variable
  3. In a parameter file (possibly YAML format).

users like this post

Comments (3)


zixian   2 months ago

NodeJS currently cannot take in command line parameters? Seems interesting.


kfwong   2 months ago

There's a npm package I used to manage environment variable call dotenv. Is this something like this you're doing?


Selim   2 months ago

Hi kfwong, Thank you for your answer. dotenv would help, but not solve the whole story. It takes config file variables into account, not pre-set environment variables nor command line options. Zixian, indeed, NodeJS can take command line parameters. I let you check the commander package. What I would like is to built up a solution, maybe by combining dotenv and commander, that will take parameters, by decreasing priority order : - command line parameters - environment variables - config file values. Exemple : Let say I have a nodeJS program that connects to a DB. If I want to have my DB_USER value as a parameter. I want to be able to : - get the DB_USER parameter from a config file, from the environment and from the command line parameters (-u, --user <USER>) - if DB_USER is defined on each source, I will chose, by order of priority : * command line parameters * environment variables * config file values.

Login to post your comment