



























@@ -21,6 +21,7 @@ import {
2121unlinkSync,
2222writeFileSync,
2323} from "node:fs";
24+import { tmpdir } from "node:os";
2425import { basename, dirname, isAbsolute, join, posix, relative } from "node:path";
2526import { fileURLToPath, pathToFileURL } from "node:url";
2627import { resolveNpmRunner } from "./npm-runner.mjs";
@@ -861,6 +862,29 @@ function shouldRunBundledPluginPostinstall(params) {
861862return true;
862863}
863864865+export function pruneOpenClawCompileCache(params = {}) {
866+const env = params.env ?? process.env;
867+const pathExists = params.existsSync ?? existsSync;
868+const remove = params.rmSync ?? rmSync;
869+const log = params.log ?? console;
870+const baseDirs = [
871+env.NODE_DISABLE_COMPILE_CACHE ? "" : env.NODE_COMPILE_CACHE,
872+join(tmpdir(), "node-compile-cache"),
873+].filter((value, index, values) => value && values.indexOf(value) === index);
874+875+for (const baseDir of baseDirs) {
876+const cacheRoot = join(baseDir, "openclaw");
877+if (!pathExists(cacheRoot)) {
878+continue;
879+}
880+try {
881+remove(cacheRoot, { recursive: true, force: true, maxRetries: 2, retryDelay: 100 });
882+} catch (error) {
883+log.warn?.(`[postinstall] could not prune OpenClaw compile cache: ${String(error)}`);
884+}
885+}
886+}
887+864888export function runBundledPluginPostinstall(params = {}) {
865889const env = params.env ?? process.env;
866890const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
@@ -871,6 +895,12 @@ export function runBundledPluginPostinstall(params = {}) {
871895if (env?.[DISABLE_POSTINSTALL_ENV]?.trim()) {
872896return;
873897}
898+pruneOpenClawCompileCache({
899+ env,
900+existsSync: pathExists,
901+rmSync: params.rmSync,
902+ log,
903+});
874904if (isSourceCheckoutRoot({ packageRoot, existsSync: pathExists })) {
875905try {
876906pruneBundledPluginSourceNodeModules({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。