CodyBugstein
CodyBugstein

Reputation: 23302

How can I view the available options for a NodeJS command line tool?

This question applies to all sorts of NodeJS command line tools, but in this case I am using a NodeJS server launcher called http-server.

There are several options available when launching this module on the command line. For example

http-server -p 8085

to launch on port 8085.

Is there any way for me to see all of the possible options displayed without having to go online to check the NPM documentation page? Is there

Upvotes: 0

Views: 75

Answers (1)

McMath
McMath

Reputation: 7188

Just use the --help flag:

http-server --help

And you will see this:

options:
  -p           Port to use [8080]
  -a           Address to use [0.0.0.0]
  -d           Show directory listings [true]
  -i           Display autoIndex [true]
  -e --ext     Default file extension if none supplied [none]
  -s --silent  Suppress log messages from output
  --cors[=headers]   Enable CORS via the "Access-Control-Allow-Origin" header
                     Optionally provide CORS headers list separated by commas
  -o [path]    Open browser window after starting the server
  -c           Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.
               To disable caching, use -c-1.
  -U --utc     Use UTC time format in log messages.

  -P --proxy   Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com

  -S --ssl     Enable https.
  -C --cert    Path to ssl cert file (default: cert.pem).
  -K --key     Path to ssl key file (default: key.pem).

  -r --robots  Respond to /robots.txt [User-agent: *\nDisallow: /]
  -h --help    Print this list and exit.

If you ever forget, just see the last option in the list.

Upvotes: 1

Related Questions