openclaw - 💡(How to fix) Fix Global npm update drops node-llama-cpp (optional peerDep not re-installed) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#57390Fetched 2026-04-08 01:50:15
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
subscribed ×2commented ×1

npm i -g openclaw@latest drops node-llama-cpp on every update, breaking local memory-search embeddings until manually re-installed.

Root Cause

node-llama-cpp is declared as an optional peerDependency:

"peerDependencies": {
  "node-llama-cpp": "^3.18.1"
},
"peerDependenciesMeta": {
  "node-llama-cpp": {
    "optional": true
  }
}

When npm performs a global update (npm i -g openclaw@latest), it replaces the package tree and does not re-install optional peer dependencies that were previously manually added. The result is that node-llama-cpp disappears from node_modules/ after every update.

Fix Action

Workaround

After every openclaw update / npm i -g openclaw@latest:

cd /opt/homebrew/lib/node_modules/openclaw  # or your global install path
npm i node-llama-cpp --no-fund --no-audit
# then restart the gateway
openclaw gateway restart

Code Example

"peerDependencies": {
  "node-llama-cpp": "^3.18.1"
},
"peerDependenciesMeta": {
  "node-llama-cpp": {
    "optional": true
  }
}

---

Cannot find package 'node-llama-cpp' imported from
  .../dist/memory-core-host-engine-embeddings-BwxuPjnM.js

---

cd /opt/homebrew/lib/node_modules/openclaw  # or your global install path
npm i node-llama-cpp --no-fund --no-audit
# then restart the gateway
openclaw gateway restart
RAW_BUFFERClick to expand / collapse

Summary

npm i -g openclaw@latest drops node-llama-cpp on every update, breaking local memory-search embeddings until manually re-installed.

Environment

  • macOS 15.3.1 (arm64, Apple M2)
  • Node.js 22.22.0
  • npm 10.x (global install)
  • OpenClaw versions affected: at least 2026.3.24 → 2026.3.28 (and 2026.3.x prior)

Root cause

node-llama-cpp is declared as an optional peerDependency:

"peerDependencies": {
  "node-llama-cpp": "^3.18.1"
},
"peerDependenciesMeta": {
  "node-llama-cpp": {
    "optional": true
  }
}

When npm performs a global update (npm i -g openclaw@latest), it replaces the package tree and does not re-install optional peer dependencies that were previously manually added. The result is that node-llama-cpp disappears from node_modules/ after every update.

Impact

  • memory_search with provider: local fails immediately after update:
    Cannot find package 'node-llama-cpp' imported from
    .../dist/memory-core-host-engine-embeddings-BwxuPjnM.js
  • Requires manual npm i node-llama-cpp inside the install path + gateway restart to recover.
  • This has occurred on at least 2026-03-26 and 2026-03-30 on the same host.

Suggested fix

Consider one of:

  1. Move node-llama-cpp to optionalDependencies instead of peerDependencies — npm will attempt to install it during npm i -g and gracefully skip on failure (e.g., unsupported platform).
  2. Post-install hook that detects and re-installs previously present optional peer deps.
  3. Runtime guidance — if node-llama-cpp is missing at startup, log a one-time warning with the exact re-install command and suggest adding it to a post-update script.

Workaround

After every openclaw update / npm i -g openclaw@latest:

cd /opt/homebrew/lib/node_modules/openclaw  # or your global install path
npm i node-llama-cpp --no-fund --no-audit
# then restart the gateway
openclaw gateway restart

extent analysis

Fix Plan

To fix the issue, we can move node-llama-cpp to optionalDependencies instead of peerDependencies. Here are the steps:

  • Update package.json to include node-llama-cpp in optionalDependencies:
"optionalDependencies": {
  "node-llama-cpp": "^3.18.1"
}
  • Remove node-llama-cpp from peerDependencies:
"peerDependencies": {}
  • Remove the peerDependenciesMeta section for node-llama-cpp:
"peerDependenciesMeta": {}
  • Run npm install to update the dependencies.

Alternatively, you can use a post-install hook to detect and re-install previously present optional peer dependencies. Here's an example of a postinstall script in package.json:

"scripts": {
  "postinstall": "npm install node-llama-cpp --no-fund --no-audit || true"
}

This script will attempt to install node-llama-cpp after every install.

Verification

To verify that the fix worked, update openclaw using npm i -g openclaw@latest and check if node-llama-cpp is still installed:

cd /opt/homebrew/lib/node_modules/openclaw
npm ls node-llama-cpp

If node-llama-cpp is installed, the command should output the version number. If not, you can try running the postinstall script manually:

npm run postinstall

Extra Tips

To prevent similar issues in the future, make sure to test your dependencies thoroughly after every update. You can also use npm dedupe to remove duplicate dependencies and ensure that your dependencies are up-to-date. Additionally, consider using a dependency manager like yarn which has better support for optional dependencies.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING