简体   繁体   English

如何查看NodeJS命令行工具的可用选项?

[英]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 . 这个问题适用于各种NodeJS命令行工具,但是在这种情况下,我使用的是称为http-server的NodeJS服务器启动器。

There are several options available when launching this module on the command line. 在命令行上启动此模块时,有几个选项可用。 For example 例如

http-server -p 8085

to launch on port 8085. 在端口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? 我有什么办法可以查看显示的所有可能选项,而不必在线检查NPM文档页面? Is there 在那儿

Just use the --help flag: 只需使用--help标志:

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. 如果您忘记了,只需查看列表中的最后一个选项即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM