Skip to content

Bundled npm in the macOS app is shipped without its own node_modules, so every plugin install fails with Cannot find module 'proc-log' #3566

Closed

Description

@itizarsa

Summary

The npm copied into the macOS app bundle at
bb.app/Contents/Resources/app.asar.unpacked/node_modules/npm is missing its
node_modules/ directory entirely. npm therefore throws before it can do any
work, and every plugin install that shells out to it fails with exit code 7.

Environment

  • bb 0.43.0 (desktop app, macOS, Darwin 25.6.0, arm64)
  • Bundled npm: 11.16.0
  • Electron Node: v24.15.0

Reproduction

  1. Install bb 0.43.0 on macOS.
  2. Install any plugin from the Extensions UI.
  3. The install fails with npm install failed (exit 7) and a MODULE_NOT_FOUND
    stack ending in npm/lib/cli/exit-handler.js.

The same failure reproduces without bb by invoking the bundled npm directly:

$ node /Applications/bb.app/Contents/Resources/app.asar.unpacked/node_modules/npm/bin/npm-cli.js --version
/Applications/bb.app/Contents/Resources/app.asar.unpacked/node_modules/npm/lib/cli/validate-engines.js:25
    throw err
    ^

Error: Cannot find module 'proc-log'

Cause

exit-handler.js:1 is require('proc-log'). npm ships its dependencies in its
own nested node_modules/, but that directory is absent from the bundle:

$ ls /Applications/bb.app/Contents/Resources/app.asar.unpacked/node_modules/npm/
bin/  docs/  lib/  man/  LICENSE  index.js  package.json

npm/node_modules/ does not exist, and proc-log is not hoisted into the
sibling app.asar.unpacked/node_modules/ either (95 entries, none of them
npm's dependencies). This looks like a packaging filter that walks into npm/
and drops nested node_modules, rather than a missing asarUnpack rule —
lib/ and bin/ made it through intact.

Impact

No plugin can be installed on a fresh 0.43.0 macOS install. The failure is not
specific to any plugin, and the surfaced error points at npm internals rather
than the actual cause, which makes it hard to diagnose from the UI.

Workaround

Replace the bundled npm with a working one (breaks the code signature and is
undone by the next update):

cd /Applications/bb.app/Contents/Resources/app.asar.unpacked/node_modules
mv npm npm.broken
ln -s "$(npm root -g)/npm" npm

Activity

  1. added theissue type on Sep 12, 2026
  2. added
    desktop
    plugins
    confirmed-repro
    on Sep 12, 2026
  3. bb-slop-cop commented on Sep 12, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Bug · High priority · Medium effort — desktop, plugins, confirmed-repro.

    Reproduction and root-cause report: REPRODUCED, high confidence, on trusted main e8f954f47 in two clean checkouts.

    Electron-builder's pnpm collection omits npm's bundled dependencies, while its file copier skips nested node_modules. Both runs copied the actual selected package files and reproduced npm exit 7 with missing proc-log; both source builds passed. The signed release and Extensions UI were not exercised.

    No PR: the fix requires packaging changes, which this rule excludes from simple fixes.

    AGENT GENERATED

  4. thomaswillner commented on Sep 12, 2026

    @thomaswillner

    Two additional data points from reproducing this on bb 0.43.0 (macOS arm64), neither of which is in the issue yet.

    1. NODE_PATH (and any CJS resolve hook) cannot work around this — npm imports some deps via ESM

    The obvious non-destructive workaround is to leave the bundle alone and point the bundled npm at an external copy of its dependencies. That does not work, and it fails silently, which is worth recording so others do not spend time on it.

    With NODE_PATH pointing at a real npm 11.16.0 dependency tree, require('proc-log') does resolve, but npm still exits 1 with no output on stdout or stderr:

    $ NODE_PATH=<npm-11.16.0>/node_modules node -e "require('proc-log'); console.log('ok')"
    ok
    $ NODE_PATH=<npm-11.16.0>/node_modules node /Applications/bb.app/Contents/Resources/app.asar.unpacked/node_modules/npm/bin/npm-cli.js --version
    $ echo $?
    1
    

    The error is invisible because the log output goes through a proc-log instance that is no longer the one npm's internals are publishing to. Subscribing to the log channel directly surfaces it:

    [verbose] stack Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'chalk' imported from
      /Applications/bb.app/.../node_modules/npm/lib/utils/display.js
    [error] code ERR_MODULE_NOT_FOUND
    

    lib/utils/display.js uses an ESM import, and ESM resolution ignores NODE_PATH and cannot be intercepted by a CJS Module._resolveFilename hook. So the dependencies have to be physically present at <npm>/node_modules, and the signature-breaking replacement already described in this issue is the only thing that works. A fix really does have to come from packaging.

    2. bb plugin update --all aborts the whole run on the first refusal

    On a host with 8 plugins showing update-available, bb plugin update --all --yes printed the refusal for the first plugin alphabetically and then stopped, leaving the remaining 7 unattempted and unreported. Running them individually shows all 8 fail identically. This makes --all under-report the blast radius of the packaging bug — worth separating from the npm issue itself if you want it tracked on its own.

    3. Minor: the surfaced npm error is head-truncated

    The message bb prints starts mid-stack:

    update refused: npm install failed (exit 7): l/modules/cjs/loader:1080:10) at resolveForCJSWithHooks ...
    

    The Error: Cannot find module 'proc-log' line — the only part that names the cause — is cut off the front, which is why this reads as an unrelated loader crash from the UI.

  5. thomaswillner commented on Sep 12, 2026

    @thomaswillner

    Correction and a useful follow-up to my previous comment: bb repairs this itself, and a retry succeeds. My "the signature-breaking replacement is the only thing that works" was wrong, and I'd rather not leave it standing.

    What I measured on 0.43.0 (macOS arm64), timestamps from stat birth times:

    1. A failed plugin update triggers the repair. bb-app/package.json declares npm: 11.16.0 as a dependency. Running bb plugin update <x> fails with exit 7 as described — and while failing, it installs npm's dependency tree into the bundle. At 12:07:37 npm/node_modules appeared; at 12:07:38–12:07:40 npm's full dependency set was also written flat into the sibling app.asar.unpacked/node_modules/, which went from 95 to 204 entries.

    2. After that, everything works. I then deliberately removed npm/node_modules again, leaving only the flat copy, and all 8 outstanding plugin updates succeeded (updated and activated); bb plugin outdated reports 0 available. So the location that matters for bb is the top-level app.asar.unpacked/node_modules, not npm/node_modules — consistent with bb spawning npm through Electron-as-node (the failing stack carries a c._load (node:electron/js2c/node_init…) frame).

    Practical upshot for anyone hitting this: run the plugin install or update a second time. The first attempt fails and repairs; the retry succeeds. No bundle surgery needed.

    Two caveats that I think still matter for the fix:

    • The repair invalidates the code signature. After it, codesign --verify --strict /Applications/bb.app returns 1 with a sealed resource is missing or invalid and ~109 file added resources. app.asar itself is untouched (sha256 unchanged), but the seal is broken until the next update replaces the bundle. Silently breaking the signature of a notarized app as a side effect of a plugin install seems worth avoiding independently of the packaging fix.
    • The first-attempt failure is still surfaced to the user as an opaque npm crash, so it reads as "plugin installs are broken" rather than "retry".

    My earlier point about NODE_PATH and ESM/chalk stands unchanged — that remains why an external dependency tree cannot substitute.

  6. added a commit that references this issue on Sep 12, 2026
    9a68828
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reprodesktopplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions