openclaw - 💡(How to fix) Fix Matrix plugin: @vector-im/matrix-bot-sdk not found after npm update [3 comments, 4 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#52124Fetched 2026-04-08 01:15:20
View on GitHub
Comments
3
Participants
4
Timeline
5
Reactions
0
Timeline (top)
commented ×3closed ×1locked ×1

The Matrix extension plugin fails to resolve @vector-im/matrix-bot-sdk after a global npm update of OpenClaw.

Root Cause

extensions/matrix/src/matrix/deps.ts uses createRequire(import.meta.url) to resolve the SDK. At runtime, import.meta.url points to the global install path (/opt/homebrew/lib/node_modules/openclaw/extensions/matrix/...), but npm install for the extension only puts dependencies in ~/.openclaw/extensions/matrix/node_modules/.

After a global update, the /opt/homebrew/... tree is rebuilt without the extension's dependencies, breaking the resolve.

Fix Action

Workaround

Manually run npm install --omit=dev in the global extension path:

cd /opt/homebrew/lib/node_modules/openclaw/extensions/matrix && npm install --omit=dev --silent

Code Example

cd /opt/homebrew/lib/node_modules/openclaw/extensions/matrix && npm install --omit=dev --silent
RAW_BUFFERClick to expand / collapse

Summary

The Matrix extension plugin fails to resolve @vector-im/matrix-bot-sdk after a global npm update of OpenClaw.

Root cause

extensions/matrix/src/matrix/deps.ts uses createRequire(import.meta.url) to resolve the SDK. At runtime, import.meta.url points to the global install path (/opt/homebrew/lib/node_modules/openclaw/extensions/matrix/...), but npm install for the extension only puts dependencies in ~/.openclaw/extensions/matrix/node_modules/.

After a global update, the /opt/homebrew/... tree is rebuilt without the extension's dependencies, breaking the resolve.

Workaround

Manually run npm install --omit=dev in the global extension path:

cd /opt/homebrew/lib/node_modules/openclaw/extensions/matrix && npm install --omit=dev --silent

Expected behavior

The resolver should either:

  1. Look in the user extension directory (~/.openclaw/extensions/matrix/node_modules/) as a fallback
  2. Or auto-install extension deps into the global path during update

Environment

  • OpenClaw 2026.3.13
  • macOS arm64
  • Node v22.22.0
  • Extension: @openclaw/matrix 2026.3.13

extent analysis

Fix Plan

To resolve the issue, we need to modify the deps.ts file to use a fallback path for resolving dependencies. We can achieve this by checking if the dependency exists in the user extension directory before attempting to resolve it from the global install path.

Step-by-Step Solution

  • Modify extensions/matrix/src/matrix/deps.ts to include a fallback path:
import { createRequire } from 'module';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const require = createRequire(import.meta.url);
const extensionDir = dirname(fileURLToPath(import.meta.url));

// Fallback path for user extension directory
const userExtensionDir = `${process.env.HOME}/.openclaw/extensions/matrix`;

try {
  // Attempt to resolve from global install path
  require.resolve('@vector-im/matrix-bot-sdk');
} catch (error) {
  // Fallback to user extension directory
  const userRequire = createRequire(`file://${userExtensionDir}/node_modules`);
  userRequire('@vector-im/matrix-bot-sdk');
}
  • Alternatively, you can also use the npm install command with the --prefix option to install dependencies in the global path during update:
npm install --prefix=/opt/homebrew/lib/node_modules/openclaw/extensions/matrix @vector-im/matrix-bot-sdk

Verification

To verify that the fix worked, run the following command:

cd /opt/homebrew/lib/node_modules/openclaw/extensions/matrix && npm start

If the dependency is resolved correctly, the application should start without any errors.

Extra Tips

  • Make sure to update the deps.ts file in the correct location, which is extensions/matrix/src/matrix/deps.ts.
  • If you're using a version control system, commit the changes to the deps.ts file to ensure that the fix is persisted across updates.

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…

FAQ

Expected behavior

The resolver should either:

  1. Look in the user extension directory (~/.openclaw/extensions/matrix/node_modules/) as a fallback
  2. Or auto-install extension deps into the global path during update

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Matrix plugin: @vector-im/matrix-bot-sdk not found after npm update [3 comments, 4 participants]