Skip to content

Commit efdba59

Browse files
fix(plugins): clear error when npm package not found (Closes #24993) (#25073)
1 parent 7aa2337 commit efdba59

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/infra/install-source-utils.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,24 @@ describe("packNpmSpecToArchive", () => {
244244
});
245245
});
246246

247+
it("returns friendly error for 404 (package not on npm)", async () => {
248+
const cwd = await createFixtureDir();
249+
mockPackCommandResult({
250+
stdout: "",
251+
stderr: "npm error code E404\nnpm error 404 '@openclaw/whatsapp@*' is not in this registry.",
252+
code: 1,
253+
});
254+
255+
const result = await runPack("@openclaw/whatsapp", cwd);
256+
257+
expect(result.ok).toBe(false);
258+
if (!result.ok) {
259+
expect(result.error).toContain("Package not found on npm");
260+
expect(result.error).toContain("@openclaw/whatsapp");
261+
expect(result.error).toContain("docs.openclaw.ai/tools/plugin");
262+
}
263+
});
264+
247265
it("returns explicit error when npm pack produces no archive name", async () => {
248266
const cwd = await createFixtureDir();
249267
mockPackCommandResult({

src/infra/install-source-utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,14 @@ export async function packNpmSpecToArchive(params: {
207207
},
208208
);
209209
if (res.code !== 0) {
210-
return { ok: false, error: `npm pack failed: ${res.stderr.trim() || res.stdout.trim()}` };
210+
const raw = res.stderr.trim() || res.stdout.trim();
211+
if (/E404|is not in this registry/i.test(raw)) {
212+
return {
213+
ok: false,
214+
error: `Package not found on npm: ${params.spec}. See https://docs.openclaw.ai/tools/plugin for installable plugins.`,
215+
};
216+
}
217+
return { ok: false, error: `npm pack failed: ${raw}` };
211218
}
212219

213220
const parsedJson = parseNpmPackJsonOutput(res.stdout || "");

0 commit comments

Comments
 (0)