npm install -g serve ,得到的可执行文件serve就是一个fileserver程序。
serve -h
serve - Static file serving and directory listing
USAGE
$ serve --help
$ serve --version
$ serve folder_name
$ serve [-l listen_uri [-l ...]] [directory]
By default, serve will listen on 0.0.0.0:3000 and serve the
current working directory on that address.
Specifying a single --listen argument will overwrite the default, not supplement it.
OPTIONS
--help Shows this help message
-v, --version Displays the current version of serve
-l, --listen listen_uri Specify a URI endpoint on which to listen (see below) -
more than one may be specified to listen in multiple places
-p Specify custom port
-s, --single Rewrite all not-found requests to `index.html`
-d, --debug Show debugging information
-c, --config Specify custom path to `serve.json`
-L, --no-request-logging Do not log any request information to the console.
-C, --cors Enable CORS, sets `Access-Control-Allow-Origin` to `*`
-n, --no-clipboard Do not copy the local address to the clipboard
-u, --no-compression Do not compress files
--no-etag Send `Last-Modified` header instead of `ETag`
-S, --symlinks Resolve symlinks instead of showing 404 errors
--ssl-cert Optional path to an SSL/TLS certificate to serve with HTTPS
Supported formats: PEM (default) and PKCS12 (PFX)
--ssl-key Optional path to the SSL/TLS certificate's private key
Applicable only for PEM certificates
--ssl-pass Optional path to the SSL/TLS certificate's passphrase
--no-port-switching Do not open a port other than the one specified when it's taken.
ENDPOINTS
Listen endpoints (specified by the --listen or -l options above) instruct serve
to listen on one or more interfaces/ports, UNIX domain sockets, or Windows named pipes.
For TCP ports on hostname "localhost":
$ serve -l 1234
For TCP (traditional host/port) endpoints:
$ serve -l tcp://hostname:1234
For UNIX domain socket endpoints:
$ serve -l unix:/path/to/socket.sock
For Windows named pipe endpoints:
$ serve -l pipe:\\.\pipe\PipeName
----------------------------------------------------
$ npm install -g live-server
$ live-server -h
Usage: live-server [-v|--version] [-h|--help] [-q|--quiet] [--port=PORT] [--host=HOST] [--open=PATH] [--no-browser] [--browser=BROWSER] [--ignore=PATH] [--ignorePattern=RGXP] [--no-css-inject] [--entry-file=PATH] [--spa] [--mount=ROUTE:PATH] [--wait=MILLISECONDS] [--htpasswd=PATH] [--cors] [--https=PATH] [--https-module=MODULE_NAME] [--proxy=PATH] [PATH]
这个live-server有点特色:
在静态网站的根目录里,运行,比如live-server --port=2345 ,就会自动打开浏览器,访问
http://127.0.0.1:2345/
No comments:
Post a Comment