The Bitwarden CLI can be built from source for development or custom distribution. The build system supports both OSS (open-source) and commercial (Bit) builds.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/bitwarden/clients/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Node.js runtime (latest LTS version recommended)
- npm package manager
- pkg for creating native executables
Development Builds
OSS Build (Open Source)
Build the open-source version of the CLI:build/bw.js.
Debug Mode
Run with Node.js inspector for debugging:Commercial Build
Build the commercial version (requires Bitwarden license files):Binary Distribution
Platform-Specific Packaging
The CLI uses pkg to create standalone native executables:- Windows (x64)
- macOS (Intel)
- macOS (ARM64)
- Linux (x64)
- Linux (ARM64)
dist/oss/windows/bw.exe or dist/bit/windows/bw.exePackaging Process
Each distribution command follows this workflow:- Build: Compile TypeScript to JavaScript with webpack
- Clean: Remove previous distribution files
- Package: Create native executable with pkg
npm run dist:oss:win executes:
Direct Packaging
To package an existing build without rebuilding:Package Configuration
Thepackage.json defines the pkg configuration:
Pkg Targets
The build system targets these platforms:win-x64: Windows x64macos-x64: macOS Intelmacos-arm64: macOS Apple Siliconlinux-x64: Linux x64linux-arm64: Linux ARM64
./build/**/* are included in the executable.
Build System
Webpack Configuration
Builds use webpack for bundling:- OSS: Default webpack configuration
- Commercial: Custom configuration at
../../bitwarden_license/bit-cli/webpack.config.js
Production Mode
Production builds setNODE_ENV=production for optimizations:
- Tree shaking
- Minification
- Dead code elimination
Testing
Run tests before building:Publishing to NPM
Publish the OSS version to npm:- Builds with production optimizations
- Publishes to npm with public access
Directory Structure
Common Issues
Build Failures
TypeScript errors: Ensure you’re using a compatible Node.js versionPackaging Failures
pkg not found: Install globallyCustom Builds
To create a custom build for specific requirements:- Modify source: Make changes to TypeScript files in
src/ - Build: Run
npm run build:ossornpm run build:oss:prod - Test: Run the built CLI with
node build/bw.js - Package: Create executables for your target platforms
Example: Custom Command
Add a custom command insrc/program.ts:
Next Steps
Commands Reference
Learn about all available CLI commands
Contributing
Contribution guidelines and development setup