Skip to main content
Every command accepts --root, --prefix and --socket. These pages write nsbx, which is what a global install gives you; npx nativesandbox works identically in every example below.

Getting the command

npm install nativesandbox does not put nsbx on your shell’s PATH. npm links a package’s binaries into node_modules/.bin, which is on PATH inside npm scripts and npx — not in your terminal. Three ways to run it:
Under nvm, a global install lands in the current Node version’s directory — switch versions and nsbx is gone until you install it there too. npx nativesandbox sidesteps that, at the cost of a slower first run.
Inside a project, a package.json script needs no prefix at all, because npm puts node_modules/.bin on PATH for scripts:

run

Creates a throwaway sandbox, runs the command, streams output as it is produced, then removes the sandbox. Exits with the command’s own status, so it composes with anything:

exec

Runs a command in a sandbox that already exists, streaming as run does. Use it with a sandbox your application created, or one run --keep --name left behind.

ls

IDLE and MAX LIFE are read off each container, not from this process — so they are what that sandbox will actually be reclaimed by, even if another process created it. Only sandboxes with the matching prefix are listed. A container this package did not create is never shown and never touched.

rm

Removes the container and its workspace. Not reversible — use stop semantics from the library if you want the cache kept. Removing something that is already gone is reported, not an error.

sweep

Runs both housekeeping passes once: stop everything past its idle timeout, retire everything past its maximum lifetime. Neither touches a sandbox with a command in flight, and neither deletes a workspace.
Useful from cron on a host where the application is not long-lived enough to sweep for itself.

Exit codes