Introduction
Nub is an all-in-one Rust toolkit for Node.js. Run TypeScript files and scripts, install dependencies, and manage Node itself — all on stock Node, with no lock-in.
One install puts every command on your PATH:
npm install -g @nubjs/nub
nub index.ts # run a TypeScript file
nub install # install dependencies (pnpm-compatible)
nub run dev # run a package.json script
nubx prisma generate # run a CLI from node_modules/.binEvery augmentation uses Node's own public extension surfaces, and the package manager reads and writes whatever lockfile your project already uses.
The toolkit
| Command | What it does | Instead of |
|---|---|---|
nub <file> | Runs JS and TS files, with .env loading and modern globals | node, tsx, ts-node, dotenv-cli |
nub run | Runs package.json scripts, 24× faster than pnpm run | npm run, pnpm run, yarn run |
nubx | Runs a local CLI, or fetches one from the registry | npx, pnpm dlx, pnpm exec, yarn dlx |
nub install | Installs dependencies against your existing npm, pnpm, or bun lockfile | npm, pnpm, yarn |
nub watch | Restarts on changes to the import graph, .env* files, and tsconfig.json | nodemon, node --watch, tsx watch |
nub node | Pins a Node version and provisions it from nodejs.org | nvm, fnm, n, volta |
nub pm | Provisions the exact package manager a project pins | corepack |
Install
Install from npm, or with pnpm add -g or yarn global add. Any of these puts nub, nubx, and nubr on your PATH.
npm install -g @nubjs/nubThe other channels:
brew install nub # macOS and Linux
mise use -g nub # mise
curl -fsSL https://nubjs.com/install.sh | bash # install scriptFor containers, the official image ghcr.io/nubjs/nub is a node base with Nub layered on. See Docker.
FROM ghcr.io/nubjs/nubIn CI, swap actions/setup-node for the setup-nub action:
- uses: actions/setup-node@v4
- uses: nubjs/setup-nub@v0Nub runs on macOS (arm64, x64), Linux (x64, arm64), and Windows (x64, arm64). It needs Node 18.19+ and provisions the version your project pins.
Install script
The install script puts a native binary in ~/.nub and adds it to your PATH. It verifies the archive against the release's SHA-256 checksum before replacing an existing install.
curl -fsSL https://nubjs.com/install.sh | bash # macOS / Linux
powershell -c "irm https://nubjs.com/install.ps1 | iex" # WindowsTwo environment variables customize it. Set them on the shell that runs the script, the right side of the pipe:
# NUB_INSTALL_DIR: install somewhere other than ~/.nub
# NUB_NO_MODIFY_PATH: truthy (1, yes, true, on) to skip the profile edit
curl -fsSL https://nubjs.com/install.sh \
| NUB_INSTALL_DIR="$HOME/.local/nub" NUB_NO_MODIFY_PATH=1 bashOn Windows, set $env:NUB_INSTALL_DIR and $env:NUB_NO_MODIFY_PATH before the irm | iex.
Upgrading
Upgrade through the channel you installed with. A script install upgrades itself in place.
npm install -g @nubjs/nub@latest # npm
brew update && brew upgrade nub # Homebrew
nub upgrade # install script, mise
nub upgrade --version <version> # reinstall or pick a versionOn a mise install, nub upgrade runs mise upgrade --bump nub, which updates the version in the mise config that selects Nub in the current directory: a project's mise.toml or your global config.
Nub and Node version independently. Upgrading Nub does not change the Node your project pins.
Package management
The installer is pnpm-compatible at the CLI and lockfile-compatible with whatever your project already uses. The npm, pnpm, and bun lockfiles round-trip; yarn's is read-only.
nub install # resolve + link node_modules, existing lockfile
nub add -E -D react # exact pin, devDeps — pnpm flag spelling
nub remove lodash
nub update
nub ci # frozen-lockfile installThe installer is optional: keep your existing package manager and use Nub for everything else. See install for lockfile fidelity per incumbent, and pm for provisioning the exact package-manager version a project pins.
Configuration
To change a default, put a nub.jsonc at the project root:
{
"$schema": "https://nubjs.com/schema/latest.json",
"preload": ["./instrumentation.ts"], // loaded before the entry file
"envFile": [".env.local"], // these instead of the defaults
"tsconfig": "./tsconfig.runtime.json", // the runtime's TypeScript config
"install": {
"minimumReleaseAge": "3d" // refuse deps newer than 3 days
}
}Unknown keys and invalid values stop the command with an error. See nub.jsonc for every field.
Offline docs
Nub bundles these docs for offline reading. The bare command prints usage and a table of contents.
nub agent docs
nub agent docs --page /docs/run # one page, as Markdown
nub agent docs --list # only the table of contents