Show HN

Bun-install

by @joeycumines

Bun-install – Global CLI installer for Bun with local monorepo support Hey HN, This is a CLI tool I initially built as a convenient and reliable way to install executable(s) from a local monorepo workspace into Bun's global package store. I had a local monorepo with workspace dependencies that needed to be installed as a whole. The commands aren't bundled, and I didn't want to manually manage dependencies. (If you want to try it out, https://github.com/open-pencil/open-pencil is what I was contributing to) I tried `bun link` initially. But linking directly meant I had to keep a separate local checkout just so branch switches wouldn't break my installed tools. `bun-install` solves this by packaging the dependencies and installing a snapshot to Bun's global store instead. I later added the `--bun` (and `--package`) options, which mirror the `bunx` option which supports using `bun` over `node`, after I ran into some annoying JS-execution-environment-related issues. I've found the recurring theme with JS-managed commands is they tend to be fragile when installed globally on machines used for development purposes, susceptible to both runtime and update time incompatibilities and breakages. I concluded this was something of a confluence of factors: A vast ecosystem, numerous runtime environments, and indirection between what's installed (the module) and what's executed (the contents of the bin directory end users add to their PATH). This project doesn't magically fix all of those, but, for me personally, it has completely resolved what was a long-standing pain point. Highlights: - Topological resolution: builds and packs sibling dependencies in order. - Command filtering: `bun-install -p my-cli tool-a`. Strips unselected commands from the manifest so they don't clobber existing global symlinks. - Shebang rewriting: forces Node shebangs to `#!/usr/bin/env bun` (and injects them if missing). Installed commands actually run under Bun. - Safe binary scanning: does an 8 KiB null-byte scan so it doesn't mangle non-node scripts or native executables. - Workspace support: install the local state, great for dev, works with internal dependencies that aren't published. - Cleans up temporary tarballs and drains TTY input on interactive prompts to prevent stdin bleed. (pre-v1, so the API might change, but the core implementation is stable). Try it out: bun add -g bun-install NPM: https://www.npmjs.com/package/bun-install GitHub: https://github.com/joeycumines/bun-install I'll be around to answer any questions. Might not respond immediately though :)

Discover more builders

Builderlust is an endless, joyful scroll of real projects people are shipping right now. Get the app to keep finding your next spark of inspiration.

📱 Coming soon to iOS & AndroidOpen in the app