openclaw - ✅(Solved) Fix Bug: media-understanding-core bundle can miss sharp after npm global install [1 pull requests, 2 comments, 3 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#77760Fetched 2026-05-06 06:21:52
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
2
Timeline (top)
commented ×2cross-referenced ×1

openclaw currently ships dist/extensions/media-understanding-core/package.json with sharp in that nested extension package, and the runtime image optimization path imports sharp from the bundled extension code. However, when openclaw is installed or updated as a global npm package, npm does not install dependencies declared only in a nested bundled extension package.json.

The result is that media/image optimization can fail at runtime with a missing sharp module unless the user manually installs sharp into the global openclaw package directory or applies a local hotfix.

Root Cause

openclaw currently ships dist/extensions/media-understanding-core/package.json with sharp in that nested extension package, and the runtime image optimization path imports sharp from the bundled extension code. However, when openclaw is installed or updated as a global npm package, npm does not install dependencies declared only in a nested bundled extension package.json.

The result is that media/image optimization can fail at runtime with a missing sharp module unless the user manually installs sharp into the global openclaw package directory or applies a local hotfix.

Fix Action

Fix / Workaround

The result is that media/image optimization can fail at runtime with a missing sharp module unless the user manually installs sharp into the global openclaw package directory or applies a local hotfix.

On a clean machine/container without a previous local hotfix:

PR fix notes

PR #77791: fix: declare sharp as root optional dependency

Description (problem / solution / changelog)

Fixes #77760.

Summary

  • Mirror bundled media-understanding-core's sharp runtime dependency in root optionalDependencies.
  • Add the matching root importer entry to pnpm-lock.yaml so package installs include sharp for the runtime path that imports it.

Why

media-understanding-core imports sharp at runtime, but the root package did not declare it. Nested bundled extension package.json dependencies are not installed as part of a normal root package install, so image/media optimization can fail in fresh installs or after updates.

Verification

  • Confirmed root optional sharp matches the bundled media-understanding-core dependency range.
  • Ran git diff --check.
  • Ran lockfile-only install for the prepared patch.

Real behavior proof

Behavior or issue addressed: The root OpenClaw package needs to make sharp available from the package root because bundled media-understanding-core imports it at runtime. Without the root manifest entry, fresh package installs or updates can miss sharp even though runtime code imports it.

Real environment tested: Live OpenClaw install on Linux VPS, Node.js runtime, OpenClaw installed under a user-local global npm path. Sensitive local usernames and exact state paths are redacted below.

Exact steps or command run after this patch: After installing sharp in the same root package path this PR declares, I verified runtime resolution from the bundled media-understanding import location, checked plugin health, checked gateway connectivity, and ran the local post-update guard.

node - <<'NODE'
const { createRequire } = require('module');
const r = createRequire('<openclaw-install>/dist/extensions/media-understanding-core/image-ops.js');
console.log(r.resolve('sharp'));
NODE

OPENCLAW_STATE_DIR=<state-dir> openclaw plugins doctor
openclaw gateway status
node /path/to/openclaw_sharp_guard.mjs

Evidence after fix: Copied live terminal output from the real setup:

$ node - <<'NODE'
const { createRequire } = require('module');
const r = createRequire('<openclaw-install>/dist/extensions/media-understanding-core/image-ops.js');
console.log(r.resolve('sharp'));
NODE
<openclaw-install>/node_modules/sharp/lib/index.js

$ OPENCLAW_STATE_DIR=<state-dir> openclaw plugins doctor
No plugin issues detected.

$ openclaw gateway status
Connectivity probe: ok
Listening: 127.0.0.1:<port>

$ node /path/to/openclaw_sharp_guard.mjs
{
  "status": "ok",
  "changed": false,
  "action": "none",
  "sharp": "<openclaw-install>/node_modules/sharp/lib/index.js"
}

Observed result after fix: sharp resolves from the OpenClaw root package node_modules, plugin doctor reports no plugin issues, the gateway connectivity probe is ok, and the post-update guard reports no repair is needed because sharp is present in the runtime path.

What was not tested: I did not publish or install a package tarball built from this PR. The live proof validates the runtime behavior this manifest change is intended to make durable; CI validates the package and lockfile changes.

Changed files

  • package.json (modified, +1/-0)
  • pnpm-lock.yaml (modified, +3/-0)

Code Example

{
  "name": "@openclaw/media-understanding-core",
  "dependencies": {
    "sharp": "^0.34.5"
  }
}

---

npm install -g openclaw@2026.5.3-1
node -e "console.log(require.resolve('openclaw/package.json'))"
# inspect the installed root package: sharp is not declared in root dependencies/optionalDependencies
# trigger an image/media optimization path that loads the bundled media-understanding-core image ops

---

{
  "optionalDependencies": {
    "sharp": "^0.34.5"
  }
}

---

{
  "dependencies": {
    "sharp": "^0.34.5"
  }
}
RAW_BUFFERClick to expand / collapse

Summary

openclaw currently ships dist/extensions/media-understanding-core/package.json with sharp in that nested extension package, and the runtime image optimization path imports sharp from the bundled extension code. However, when openclaw is installed or updated as a global npm package, npm does not install dependencies declared only in a nested bundled extension package.json.

The result is that media/image optimization can fail at runtime with a missing sharp module unless the user manually installs sharp into the global openclaw package directory or applies a local hotfix.

Why this happens

The published package contains a nested package manifest similar to:

{
  "name": "@openclaw/media-understanding-core",
  "dependencies": {
    "sharp": "^0.34.5"
  }
}

But npm install -g openclaw resolves dependencies from the root published openclaw/package.json. It does not recurse into dist/extensions/media-understanding-core/package.json and install that package's dependencies as a separate package install.

At runtime, the bundled media code imports sharp from the media image operations path, so a root-level dependency declaration is needed for the published package.

Reproduction

On a clean machine/container without a previous local hotfix:

npm install -g [email protected]
node -e "console.log(require.resolve('openclaw/package.json'))"
# inspect the installed root package: sharp is not declared in root dependencies/optionalDependencies
# trigger an image/media optimization path that loads the bundled media-understanding-core image ops

Expected: image/media optimization can load sharp from the installed OpenClaw package dependency graph.

Actual: the bundled extension package declares sharp, but npm global install does not install dependencies from that nested manifest, so runtime media image operations can fail with Cannot find package 'sharp' / Cannot find module 'sharp' depending on the loader path.

Suggested fix

Add sharp to the root published openclaw package dependency graph, preferably as optionalDependencies if media optimization is intended to degrade gracefully when native image tooling cannot install, or as dependencies if media-understanding-core is considered a required runtime capability.

Minimal package-level shape:

{
  "optionalDependencies": {
    "sharp": "^0.34.5"
  }
}

or:

{
  "dependencies": {
    "sharp": "^0.34.5"
  }
}

The existing nested extensions/media-understanding-core/package.json dependency can remain useful for workspace/local development, but it is not sufficient for the npm-published global package runtime.

Notes

This is separate from failures where sharp is present but fails to build/install on a specific OS or Node version. This issue is about the root published package not declaring a dependency that bundled runtime code imports.

extent analysis

TL;DR

Add sharp to the root openclaw package's dependencies or optionalDependencies to ensure it's installed with the global package.

Guidance

  • Verify the issue by checking if sharp is declared in the root openclaw package's package.json after a global install.
  • To fix, add sharp to the root package's dependencies if media optimization is a required capability, or to optionalDependencies if it should degrade gracefully.
  • Ensure the version of sharp in the root package matches the one declared in the nested media-understanding-core package.
  • After updating the root package, re-install the global package to test the fix.

Example

The updated openclaw/package.json could include:

{
  "dependencies": {
    "sharp": "^0.34.5"
  }
}

or

{
  "optionalDependencies": {
    "sharp": "^0.34.5"
  }
}

Notes

This fix assumes that the issue is solely due to the missing dependency declaration in the root package, and not related to sharp installation or build failures on specific OS or Node versions.

Recommendation

Apply the workaround by adding sharp to the root package's dependencies or optionalDependencies, as this will ensure the required dependency is installed with the global package.

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