openclaw - ✅(Solved) Fix 🐛 [Bug] Gateway crashing on plugin initialization due to empty dependencies in isolated package.json (npm v11 / Node v25) [1 pull requests, 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#74949Fetched 2026-05-01 05:39:42
View on GitHub
Comments
3
Participants
4
Timeline
9
Reactions
3
Author
Timeline (top)
commented ×3cross-referenced ×3closed ×1mentioned ×1

Error Message

When running with the latest Node v25.6.1 and npm v11, npm's arborist dedupe algorithm fails when parsing dependency trees without explicit versions, throwing a TypeError: Invalid Version: error. By injecting the specs into the package.json, npm resolves the ideal-tree cleanly without raising the Invalid Version exception. I've tested this patch locally and it completely resolves the crash loop.

Root Cause

🛠️ Root Cause

In /dist/bundled-runtime-deps-BdEAdjwi.js (or the corresponding source file), the package.json is hardcoded to omit dependencies, and the specs are passed directly via npm CLI arguments. In newer npm versions, building the ideal-tree in an empty package root with CLI specs causes version parsing to crash during deduping.

Fix Action

Fix / Workaround

By injecting the specs into the package.json, npm resolves the ideal-tree cleanly without raising the Invalid Version exception. I've tested this patch locally and it completely resolves the crash loop.

PR fix notes

PR #74966: fix(plugins): always include dependencies field in isolated package.json for npm v11 compatibility

Description (problem / solution / changelog)

Summary

Fixes #74949

npm v11's arborist fails with TypeError: Invalid Version when the staging package.json has no dependencies field and specs are passed only via CLI arguments. The root cause is in createNpmInstallExecutionManifest: the dependencies object was conditionally omitted when installSpecs is empty.

Before:

...(Object.keys(sortedDependencies).length > 0 ? { dependencies: sortedDependencies } : {}),

After:

dependencies: sortedDependencies,

This ensures arborist always finds a dependencies field to parse, even when empty, avoiding the Invalid Version crash loop.

Files changed

  • src/plugins/bundled-runtime-deps-materialization.ts — always emit dependencies (1 line)
  • src/plugins/bundled-runtime-deps.test.ts — regression test for empty-spec manifest

Test plan

  • pnpm vitest run src/plugins/bundled-runtime-deps.test.ts — 114/114 pass
  • New regression test: always includes a dependencies field in the install manifest, even when specs are empty

Changed files

  • src/plugins/bundled-runtime-deps-materialization.ts (modified, +1/-1)
  • src/plugins/bundled-runtime-deps.test.ts (modified, +14/-1)

Code Example

{
  "name": "openclaw-runtime-deps-install",
  "private": true
}

---

if (isolatedExecutionRoot) {
  fs.writeFileSync(path.join(installExecutionRoot, "package.json"),
    `${JSON.stringify({name:"openclaw-runtime-deps-install",private:true},null,2)}\n`, "utf8");
}

---

if (isolatedExecutionRoot) {
  const __deps = {};
  for (const __s of params.missingSpecs) {
    const __i = __s.startsWith("@") ? __s.lastIndexOf("@") : __s.indexOf("@");
    if (__i > 0) __deps[__s.slice(0, __i)] = __s.slice(__i+1);
  }
  fs.writeFileSync(path.join(installExecutionRoot, "package.json"),
    `${JSON.stringify({name:"openclaw-runtime-deps-install",private:true,dependencies:__deps},null,2)}\n`,
    "utf8");
}
RAW_BUFFERClick to expand / collapse

🐛 [Bug] Gateway crashing on plugin initialization due to empty dependencies in isolated package.json (npm v11 / Node v25)

📌 Description

When initializing plugins, OpenClaw creates an isolated package.json for staging bundled runtime dependencies. However, it currently creates a package.json without a dependencies field:

{
  "name": "openclaw-runtime-deps-install",
  "private": true
}

When running with the latest Node v25.6.1 and npm v11, npm's arborist dedupe algorithm fails when parsing dependency trees without explicit versions, throwing a TypeError: Invalid Version: error. This causes all plugins (telegram, browser, anthropic, etc.) to fail their dependency installation, resulting in a continuous gateway crash/restart loop.

🛠️ Root Cause

In /dist/bundled-runtime-deps-BdEAdjwi.js (or the corresponding source file), the package.json is hardcoded to omit dependencies, and the specs are passed directly via npm CLI arguments. In newer npm versions, building the ideal-tree in an empty package root with CLI specs causes version parsing to crash during deduping.

✅ Proposed Solution (Code Snippet)

Instead of an empty package, parse params.missingSpecs and populate the dependencies field in the generated package.json.

Before:

if (isolatedExecutionRoot) {
  fs.writeFileSync(path.join(installExecutionRoot, "package.json"),
    `${JSON.stringify({name:"openclaw-runtime-deps-install",private:true},null,2)}\n`, "utf8");
}

After:

if (isolatedExecutionRoot) {
  const __deps = {};
  for (const __s of params.missingSpecs) {
    const __i = __s.startsWith("@") ? __s.lastIndexOf("@") : __s.indexOf("@");
    if (__i > 0) __deps[__s.slice(0, __i)] = __s.slice(__i+1);
  }
  fs.writeFileSync(path.join(installExecutionRoot, "package.json"),
    `${JSON.stringify({name:"openclaw-runtime-deps-install",private:true,dependencies:__deps},null,2)}\n`,
    "utf8");
}

💻 Environment

  • OS: macOS (Apple Silicon)
  • Node: v25.6.1
  • npm: v11.x
  • OpenClaw version: 2026.4.24

By injecting the specs into the package.json, npm resolves the ideal-tree cleanly without raising the Invalid Version exception. I've tested this patch locally and it completely resolves the crash loop.

extent analysis

TL;DR

Update the package.json generation to include dependencies from params.missingSpecs to prevent npm's arborist dedupe algorithm from failing.

Guidance

  • Verify that the params.missingSpecs array contains the expected dependency specifications before populating the dependencies field in the generated package.json.
  • Test the updated code with different dependency versions to ensure the fix works across various scenarios.
  • Consider adding error handling for cases where params.missingSpecs is empty or malformed.
  • Review the npm documentation for any changes to the arborist algorithm or dependency parsing in version 11.

Example

The provided code snippet demonstrates how to populate the dependencies field in the generated package.json:

const __deps = {};
for (const __s of params.missingSpecs) {
  const __i = __s.startsWith("@") ? __s.lastIndexOf("@") : __s.indexOf("@");
  if (__i > 0) __deps[__s.slice(0, __i)] = __s.slice(__i+1);
}

Notes

This fix assumes that params.missingSpecs contains the necessary dependency specifications. If this is not the case, additional changes may be required to populate the dependencies field correctly.

Recommendation

Apply the proposed workaround by updating the package.json generation to include dependencies from params.missingSpecs, as this has been tested and verified to resolve the crash loop issue.

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

openclaw - ✅(Solved) Fix 🐛 [Bug] Gateway crashing on plugin initialization due to empty dependencies in isolated package.json (npm v11 / Node v25) [1 pull requests, 3 comments, 4 participants]