Bug Description
The getExtensionApiImportSpecifiers() function in index.ts does not support Windows platform paths, causing memory-reflection and other features that depend on extensionAPI.js to fail on Windows.
Error Message
Error: Unable to load OpenClaw embedded runtime API. Set OPENCLAW_EXTENSION_API_PATH if runtime layout differs.
Attempts: openclaw/dist/extensionAPI.js: Cannot find module 'openclaw/dist/extensionAPI.js'
Require stack:
- C:\Users\admin\.openclaw\extensions\memory-lancedb-pro\index.ts | file:///C:/usr/lib/node_modules/openclaw/dist/extensionAPI.js
Root Cause
The getExtensionApiImportSpecifiers() function only checks Unix/macOS paths:
function getExtensionApiImportSpecifiers(): string[] {
const envPath = process.env.OPENCLAW_EXTENSION_API_PATH?.trim();
const specifiers: string[] = [];
if (envPath) specifiers.push(toImportSpecifier(envPath));
specifiers.push("openclaw/dist/extensionAPI.js");
try {
specifiers.push(toImportSpecifier(requireFromHere.resolve("openclaw/dist/extensionAPI.js")));
} catch {
// ignore resolve failures and continue fallback probing
}
specifiers.push(toImportSpecifier("/usr/lib/node_modules/openclaw/dist/extensionAPI.js"));
specifiers.push(toImportSpecifier("/usr/local/lib/node_modules/openclaw/dist/extensionAPI.js"));
// Missing: Windows npm global path (%APPDATA%\npm\node_modules\...)
return [...new Set(specifiers.filter(Boolean))];
}
Missing Windows Paths
On Windows, npm global packages are typically installed to:
%APPDATA%\npm\node_modules\openclaw\dist\extensionAPI.js
Suggested Fix
Add Windows-specific fallback path using process.env.APPDATA:
// Windows npm global
const windowsNpmPath = path.join(process.env.APPDATA || '', 'npm', 'node_modules', 'openclaw', 'dist', 'extensionAPI.js');
specifiers.push(toImportSpecifier(windowsNpmPath));
Environment
- OS: Windows
- npm global path:
C:\Users\{username}\AppData\Roaming\npm\node_modules\openclaw\dist\extensionAPI.js
- OPENCLAW_EXTENSION_API_PATH: Currently required as workaround
Workaround
Manually set OPENCLAW_EXTENSION_API_PATH environment variable to:
%APPDATA%\npm\node_modules\openclaw\dist\extensionAPI.js
Bug Description
The
getExtensionApiImportSpecifiers()function inindex.tsdoes not support Windows platform paths, causingmemory-reflectionand other features that depend onextensionAPI.jsto fail on Windows.Error Message
Root Cause
The
getExtensionApiImportSpecifiers()function only checks Unix/macOS paths:Missing Windows Paths
On Windows, npm global packages are typically installed to:
%APPDATA%\npm\node_modules\openclaw\dist\extensionAPI.jsSuggested Fix
Add Windows-specific fallback path using
process.env.APPDATA:Environment
C:\Users\{username}\AppData\Roaming\npm\node_modules\openclaw\dist\extensionAPI.jsWorkaround
Manually set
OPENCLAW_EXTENSION_API_PATHenvironment variable to: