OptionalCGIOptionalconfigConfig file name.
OptionaldirDirectory to serve.
OptionalexecCommand to execute when watch glob matches.
OptionalglobWatch this glob. When it changes, execute the exec command.
OptionalheadersExtra headers to add to every response.
OptionalhostHostname or IP address to listen on. "::" for everything.
OptionalindexList of files to try in order if a directory is specified as URL.
OptionalinitialIf glob is specified, run the exec command on startup as well as on file change.
Optionalipv6Listen on IPv6 only, if host supports both IPv4 and IPv6.
OptionalopenPath to open.
OptionalopenFor 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.
Optionaloptions: 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}});
OptionalportTCP Port to listen on.
OptionalprefixMake all of the URLs served have paths that start with this prefix, followed by a slash.
OptionalrawIf true, do not process markdown to HTML.
OptionalscriptIf true, append script to HTML to cause automatic refreshes.
OptionalshutShut down the server when we are asked this many times.
OptionalsignalAbort this to stop the server.
OptionaltimeoutTime, in ms, to let glob commands run before termination.
Pass files of these MIME types to a CGI handler on the command line.