Skip to content

fix(docker): install Node/npm at runtime for npm-based CLI Apps#7

Merged
Ho1yShif merged 1 commit into
mainfrom
fix/cli-apps-install-npm-check
Jul 9, 2026
Merged

fix(docker): install Node/npm at runtime for npm-based CLI Apps#7
Ho1yShif merged 1 commit into
mainfrom
fix/cli-apps-install-npm-check

Conversation

@Ho1yShif

@Ho1yShif Ho1yShif commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Problem

Installing an npm-based CLI App (e.g. hyperframes) from the WebUI failed with:

GET /api/settings/cli-apps/install?name=hyperframes → 400 Bad Request
"npm is not installed"

Root cause

The runtime image (ghcr.io/astral-sh/uv:python3.12-bookworm-slim) is Python-only. Node/npm existed only in the discarded webui-builder stage, so at runtime shutil.which("npm") in nanobot/apps/cli/service.py returned None and raised CliAppError("npm is not installed") — which defaults to HTTP 400.

A second latent issue: the gateway runs as the non-root nanobot user, and npm install -g defaults to /usr/local, which that user can't write to (EACCES).

Fix

  • Copy Node + npm from the existing webui-builder stage into the runtime image (reuses the toolchain already in the build — no second download).
  • Route npm install -g to a user-writable prefix (/home/nanobot/.npm-global) and put its bin/ on PATH, so installs succeed as nanobot and the installed CLI resolves via shutil.which(entry_point).

Verification

Built the image and ran the exact registry command as the nanobot user:

$ npm install -g hyperframes
install ok: /home/nanobot/.npm-global/bin/hyperframes

Both node --version / npm --version also run as a build-time check.

Notes

  • Adds Node (~150MB) to the runtime image.
  • .npm-global lives in the image home, not the mounted disk, so npm-installed CLIs are ephemeral across redeploys (same as the existing pip apps). Can be moved onto the disk in a follow-up if persistence is desired.

🤖 Generated with Claude Code

npm-based CLI Apps (e.g. hyperframes) failed to install from the WebUI
with a 400 "npm is not installed". The runtime image is Python-only —
Node/npm lived solely in the discarded webui-builder stage — so the
install path's shutil.which("npm") returned None and raised CliAppError.

Copy Node + npm from the webui-builder stage into the runtime image and
route `npm install -g` to a user-writable prefix (/home/nanobot/.npm-global)
on PATH, so installs succeed as the non-root nanobot user and the
resulting CLI resolves via shutil.which(entry_point).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Ho1yShif Ho1yShif merged commit 51cd494 into main Jul 9, 2026
1 of 5 checks passed
@Ho1yShif Ho1yShif deleted the fix/cli-apps-install-npm-check branch July 9, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant