Bare CLI
Showing every release, with badges on the differences.
Reference for the bare command: evaluate a script, start a REPL, and the flags for inspecting, evaluating, and printing.
This page tracks the Bare CLI surface as of Bare 1.37.1 (the flags are unchanged since 1.28.1). --inspect-port and --expose-gc are annotated below with the release that added them.
The bare command runs a script on the Bare runtime or starts a REPL. Install it globally with:
npm i -g bareUsage
bare [flags] [filename] [...args]Evaluate a script or start a REPL session if no script is provided.
Arguments
[filename] Optional. The name of a script to evaluate
[...args] Additional arguments made available to the scriptArguments after filename are passed through to the script and are available as Bare.argv. filename is resolved against the current directory, and Bare.argv becomes the executable, the resolved path of filename, and then ...args.
Flags
--version|-v Print the Bare version
--eval|-e <script> Evaluate an inline script
--print|-p <script> Evaluate an inline script and print the result
--inspect Activate the inspector
--inspect-port <port> Configure the port on which the inspector will run (default: 9229)
--expose-gc Expose garbage collection APIs
--help|-h Show help--print wraps its script as console.log(<script>), so it prints the value of an expression. --version prints Bare.version, which has a leading v. An unknown flag before filename prints unknown flag: <name> to stderr, and an invalid flag, such as --eval with no script, prints invalid flag: <name>. Each exits with status 1. Everything after filename goes to the script, including anything that looks like a flag.
Inspector
--inspect starts the inspector on --inspect-port as the script starts. Where the platform has SIGUSR1, sending that signal to a running bare process starts the inspector too, without --inspect. The inspector server doesn't keep the process alive.
The bare command that npm i -g bare installs is a Node.js script that starts the Bare binary as a child process, and it ignores SIGUSR1. Send the signal to the child process instead, which is the bare binary inside the bare-runtime-<platform>-<arch> package.
Environment
If BARE_CHANNEL_FD is a file descriptor and BARE_CHANNEL_SERIALIZATION_MODE is binary, bare opens that descriptor as an IPC pipe and sets Bare.IPC to it, so a parent process can talk to the script it spawned. Requires Bare >=1.28.7. With anything else, Bare.IPC stays null.
Module loading
The specified filename (or inline --eval script) is run with Module.load(), which resolves both CommonJS and ESM and provides interop between them. An inline script is resolved against the current directory. For the supported formats and resolution rules, see bare-module.
With no filename, --eval or --print, bare starts a REPL on the global scope, with require() resolving against the current directory. The REPL exits when you close it, or once the inspector server has closed if one is running.
See also
- Bare runtime API—the
Bareglobal available to scripts you run. - Inside Bare—what the runtime is and why it's minimal.
- Start from the hello-pear-bare template—a terminal app run with
bare bin.js. - Bare modules—the standard library available to scripts.
- Build a CLI executable with pear make—compile a script you run with
bareinto a standalone executable, from Pear 3.7.0.
Last updated on