Optional
caOptional
caSubject Distinguished Name for CA.
Optional
certRelative to cwd.
Optional
CGIPass files of these MIME types to a CGI handler on the command line.
Optional
configConfig file name.
Optional
dirDirectory to serve.
Optional
execCommand to execute when watch glob matches.
Optional
forceAlways create a new CA cert, even if one exists and is valid.
Optional
forceAlways create a new certificate, even if one exists and is valid.
Optional
globWatch this glob. When it changes, execute the exec command.
Optional
headersExtra headers to add to every response.
Optional
hostHostname or IP address to listen on. "::" for everything.
Optional
indexList of files to try in order if a directory is specified as URL.
Optional
initialIf glob is specified, run the exec command on startup as well as on file change.
Optional
ipv6Listen on IPv6 only, if host supports both IPv4 and IPv6.
Optional
logAlready have a log file?
Optional
logLog to a file instead.
Optional
log0 for info. +verbose, -quiet.
Optional
minMinimum number of days the serve can run. Ensure the cert will good at least this long.
Optional
noIf true, do not read the key.
Optional
notCertificate invalid after this many days, server restart required.
Optional
openPath to open.
Optional
openFor testing only.
Open stuff like URLs, files, executables. Cross-platform.
Uses the command open
on macOS, start
on Windows and xdg-open
on other platforms.
There is a caveat for double-quotes on Windows where all double-quotes are stripped from the target
.
The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
Optional
options: OptionsThe spawned child process. You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
import open, {apps} from 'open';
// Opens the image in the default image viewer.
await open('unicorn.png', {wait: true});
console.log('The image viewer app quit');
// Opens the URL in the default browser.
await open('https://sindresorhus.com');
// Opens the URL in a specified browser.
await open('https://sindresorhus.com', {app: {name: 'firefox'}});
// Specify app arguments.
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
// Opens the URL in the default browser in incognito mode.
await open('https://sindresorhus.com', {app: {name: apps.browserPrivate}});
Optional
portTCP Port to listen on.
Optional
prefixMake all of the URLs served have paths that start with this prefix, followed by a slash.
Optional
rawIf true, do not process markdown to HTML.
Optional
scriptIf true, append script to HTML to cause automatic refreshes.
Optional
shutShut down the server when we are asked this many times.
Optional
signalAbort this to stop the server.
Optional
timeoutTime, in ms, to let glob commands run before termination.
Relative to cwd.