Skip to content

fix(uninstall): preserve user-installed Node.js#5

Merged
taoyizhi68 merged 1 commit into
mainfrom
fix/preserve-user-installed-nodejs-on-uninstall
May 15, 2026
Merged

fix(uninstall): preserve user-installed Node.js#5
taoyizhi68 merged 1 commit into
mainfrom
fix/preserve-user-installed-nodejs-on-uninstall

Conversation

@taoyizhi68
Copy link
Copy Markdown
Contributor

Problem

Uninstalling MicroClaw via the desktop Uninstall MicroClaw shortcut removes Node.js even when the user installed it themselves before installing MicroClaw. After uninstall, build.ps1 fails with:

ERROR: node.exe not found in any of:
  - C:\Program Files\nodejs
  - C:\Users\<user>\AppData\Local\Programs\nodejs
  - C:\Users\<user>\.openclaw-node
  - PATH (Get-Command node.exe)

The cause is in _msi_uninstall_node: it enumerates HKCU/HKLM Uninstall registry entries and runs msiexec /x on any entry whose DisplayName contains node.js, then _uninstall_clean_node rmtree's self.node_dir (typically C:\Program Files\nodejs). It has no way to tell apart "Node we installed" from "Node the user installed".

Fix

Add an ownership marker:

  • install_node_windows writes ~/.openclaw/.node-installed-by-microclaw containing the install path on a successful MSI install.
  • _uninstall_clean_node reads the marker:
    • No marker -> log "未发现 MicroClaw 安装 Node 的标记 — 保留用户自带的 Node.js", skip MSI uninstall, skip rmtree of self.node_dir, skip removing %APPDATA%\npm from PATH. The legacy ~/.openclaw-node directory is still cleaned (always ours).
    • Marker present -> only operate on the recorded path (+ legacy dirs).
  • _msi_uninstall_node now requires the recorded path and additionally filters registry entries by InstallLocation, so unrelated Node MSIs are never touched.

Matrix

Node origin Marker Uninstall behavior
Installed by MicroClaw (MSI) ✅ written Removed (as before)
User had Node at standard path; MicroClaw reused it ❌ none Preserved
Non-standard user Node + MicroClaw also MSI-installed its own ✅ written for our path; user's path not in registry match Only ours removed
Legacy zip-extracted ~/.openclaw-node n/a Always cleaned

Test

Repro before fix:

  1. Manually install Node.js to C:\Program Files\nodejs
  2. Install MicroClaw (it reuses the existing Node)
  3. Click Uninstall MicroClaw desktop shortcut
  4. build.ps1 -> fails: node.exe not found

After fix: step 4 succeeds; the user's Node.js remains intact.

The MicroClaw uninstaller previously ran _msi_uninstall_node and rmtree'd the Node install directory unconditionally — matching any MSI entry whose DisplayName contained 'node.js'. This wiped Node.js even when the user had installed it themselves before installing MicroClaw, breaking subsequent `build.ps1` runs that depend on a pre-existing Node.js.

Now install_node_windows writes ~/.openclaw/.node-installed-by-microclaw recording the install path when MicroClaw itself installs Node via MSI. _uninstall_clean_node and _msi_uninstall_node consult this marker:

- No marker  -> skip MSI uninstall, skip rmtree of self.node_dir, skip removing %APPDATA%\npm from PATH. The legacy ~/.openclaw-node dir is still cleaned (always ours).
- Marker present -> only uninstall MSI entries whose InstallLocation matches the recorded path, and only rmtree that path + legacy dirs.
@taoyizhi68 taoyizhi68 merged commit 7e4f51d into main May 15, 2026
0 of 2 checks passed
taoyizhi68 added a commit that referenced this pull request May 15, 2026
The MicroClaw uninstaller previously ran _msi_uninstall_node and rmtree'd the Node install directory unconditionally - matching any MSI entry whose DisplayName contained 'node.js'. This wiped Node.js even when the user had installed it themselves before installing MicroClaw, breaking subsequent `build.ps1` runs that depend on a pre-existing Node.js.

Now install_node_windows writes ~/.openclaw/.node-installed-by-microclaw recording the install path when MicroClaw itself installs Node via MSI. _uninstall_clean_node and _msi_uninstall_node consult this marker:

- No marker  -> skip MSI uninstall, skip rmtree of self.node_dir, skip removing %APPDATA%\npm from PATH. The legacy ~/.openclaw-node dir is still cleaned (always ours).
- Marker present -> only uninstall MSI entries whose InstallLocation matches the recorded path, and only rmtree that path + legacy dirs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants