Bare: the small JS runtime
Bare is a minimal JavaScript runtime:
V8 plus a tiny native core, with everything else — fs, tcp, tty, crypto —
shipped as addon modules instead of baked in. It is what Pear terminal
apps and mobile embeddings actually run on.
Why it matters for P2P:
- Small enough to embed. Bare runs inside iOS/Android apps (bare-kit), so
the same backend that powers your desktop node runs on a phone.
- No monolith to wait on. Modules version independently; the runtime
stays tiny.
Node-compatible-ish, by choice
Bare mirrors Node's module shapes (bare-fs ≈ fs, bare-process ≈process, …). The trick for code that runs on both is conditional
imports in package.json:
"imports": {
"#fs": { "bare": "bare-fs", "default": "./shims/node-fs.js" },
"#process": { "bare": "bare-process", "default": "./shims/node-process.js" }
}
Then require('#fs') resolves to the right implementation per runtime.
p2pbuilders isolates every platform touchpoint behind one _rt.js shim —
that single decision is why the same backend boots under Node, Pear and
bare-kit unmodified.
Try it
npm i bare bare-process
./node_modules/bare/bin/bare app.js
In app code, detect the runtime when you must:
const process = (typeof Bare !== 'undefined')
? require('bare-process')
: global.process
Rule we live by: never sprinkle runtime checks through app logic. One shim
module owns the differences; everything else imports the shim.