update-nanoclaw: controller imports `setup/gateways/` (and npm deps) that the documented extraction doesn't provide — `prepare` crashes with MODULE_NOT_FOUND (regression after #3750)
Version
NanoClaw 2.4.0, main at c313d061 (still present at d4ff64f4, re-checked 2026-09-26). Updating from v2.3.0 (d96dde93 + local commits). Node v22.23.2, pnpm 10.34.5, Linux.
Steps to reproduce
- On a v2.3.x install, follow
.claude/skills/update-nanoclaw/SKILL.mdfromorigin/main(c313d061), step 1:controller_dir="$(cd "$(mktemp -d)" && pwd -P)" git archive "$upstream_ref" scripts src/install-slug.ts | tar -x -C "$controller_dir" - Run step 2:
pnpm exec tsx "$controller_dir/scripts/update-nanoclaw.ts" prepare \ --project-root "$PWD" --upstream-ref origin/main --strategy merge
Expected
prepare creates the staging worktree and returns a nanoclaw-update/v1 result.
Observed
Error: Cannot find module '../../setup/gateways/install.js'
requireStack: [ .../scripts/update/transaction.ts, .../scripts/update-nanoclaw.ts ]scripts/update/transaction.ts:6-7 imports ../../setup/gateways/install.js and ../../setup/gateways/selection.js (added in d5c7cccc, #3816). Those modules in turn import setup/lib/skill-driver.ts → @clack/prompts, so extracting setup/ alone is not enough either: the temp dir has no node_modules, so npm imports fail next.
A second instance of the same problem: step 2's documented resume command runs "$stageRoot/scripts/update-nanoclaw.ts". The staging worktree has no node_modules until validate installs them, so resume fails with Cannot find package '@clack/prompts' imported from <stageRoot>/setup/lib/skill-driver.ts.
Nothing is mutated in either case (the live tree stays clean), but the update cannot proceed as documented.
Workaround used: extract scripts setup src package.json tsconfig.json into the controller dir and symlink the project's node_modules into it; run resume/validate from that controller instead of $stageRoot.
Suggested fix
- Extract
setup/too (git archive "$upstream_ref" scripts setup src/install-slug.ts), and resolve npm packages, e.g. by running the controller withNODE_PATH="$PWD/node_modules"or symlinkingnode_modulesintocontroller_dir. - Better long-term: have the controller lazy-import the gateway modules only in
validate/cutover(after staging deps are installed), or add a CI test that runsprepare→resumefrom a controller extracted exactly as the SKILL.md documents, so import-graph growth can't silently break step 1 again (this is the third occurrence: #3800, #3869, this one). - In SKILL.md, run
resumefrom$controller_dirrather than$stageRoot, or install staging deps beforeresume.
Source: nanocoai/nanoclaw