BetterPack - A Universal Node.js Package Manager CLI

BetterPack (bpack) is a command-line interface (CLI) tool designed to simplify package management across different Node.js ecosystems. It automatically detects the package manager used in your project (npm, yarn, or pnpm) and translates universal commands into the appropriate commands for that manager.

Installation

You can install BetterPack globally using your favorite package manager:

npm

npm install -g betterpack

yarn

yarn global add betterpack

pnpm

pnpm add -g betterpack

bun

bun add -g betterpack

Supported Package Managers

Universal Commands

BetterPack provides a consistent set of commands:

Betterpack Commands

bpack gemini

Starts an interactive chat session with Google's Gemini AI.

bpack host

Starts a local web server in the current directory.

bpack listversions

Lists the installed versions of all supported package managers.

bpack manage

A suite of commands for managing global packages and the tool itself.

bpack node

Executes a JavaScript file using Node.js.

bpack watch

Watches a file for changes and automatically restarts the process.

bpack repair

Attempts to repair a broken betterpack installation by reinstalling it and clearing package manager caches.

bpack noinstall

Runs a command without installing the package globally, using pnpm dlx or yarn dlx.

bpack create-shortcut

Creates a shortcut for a bpack command. For example, bpack create-shortcut bl bpack list will allow you to run bpack list by simply typing bl.

bpack git

A wrapper for common git commands.

Usage

Once installed, you can use `bpack` from any Node.js project directory. BetterPack will automatically detect the package manager from the lock file (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`) and use it to run the commands.

Examples

Install dependencies:

bpack install

Add a new dependency:

bpack add express

Run a script from your `package.json`:

bpack run dev

Configuration

BetterPack works out of the box with no configuration required. However, you can customize its behavior using a .bpackrc file in your project's root directory. The configuration file should be in JSON format.

Example .bpackrc

{
  "defaultPackageManager": "pnpm",
  "autoCommit": true
}

Options

How it Works

  1. Detection: BetterPack checks for the presence of package-lock.json (for npm), yarn.lock (for yarn), or pnpm-lock.yaml (for pnpm) in the current directory to identify the active package manager.
  2. Translation: Based on the detected package manager, it translates the universal command (e.g., install) into the manager-specific command (e.g., npm install, yarn install, pnpm install).
  3. Execution: The translated command is then executed using Node.js's child_process.spawn.

Support the Project

Buy Me a Coffee