Skip to content

[CLI] MODULE_NOT_FOUND 'buffer/' when installing globally via pnpm #20547

@xsfunc

Description

@xsfunc

Steps To Reproduce

Environment

  • Node.js: v26.1.0
  • pnpm: latest
  • Toolchain: mise

Steps to reproduce

  1. Install @bitwarden/cli globally using pnpm (or via mise with pnpm backend):
    mise use -g npm:@bitwarden/cli
  2. Run the CLI:
    bw -v
    
    

Expected Result

CLI executes successfully and returns the version number.

Actual Result

Crash with MODULE_NOT_FOUND:

node:internal/modules/cjs/loader:1505
  throw err;
  ^
Error: Cannot find module 'buffer/'
Require stack:
- /.../node_modules/@bitwarden/cli/build/bw.js
    at Object.<anonymous> (/.../node_modules/@bitwarden/cli/build/bw.js:79140:12) {
  code: 'MODULE_NOT_FOUND'
}

Screenshots or Videos

No response

Additional Context

Root cause & Potential Fix

The compiled file build/bw.js contains a require('buffer/') call with a trailing slash. Because pnpm enforces a strict, non-flat node_modules structure, this specific import path fails to resolve the module.

Removing the trailing slash (require('buffer')) or properly defining the required polyfill in the dependencies resolves the problem for strict package managers like pnpm.

Operating System

Linux

Operating System Version

No response

Shell

Bash

Build Version

2026.4.1

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcliCLI Application

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions