Skip to content

[Bug] Plugin fails to load when openclaw is globally installed on Windows: Cannot find module 'openclaw/plugin-sdk/channel-config-schema' #47

@gzsiang

Description

@gzsiang

[Bug Report]

Summary

Plugin fails to load with error Cannot find module 'openclaw/plugin-sdk/channel-config-schema' when openclaw is globally installed on Windows.

Steps to Reproduce

  1. Install openclaw globally via npm: npm install -g openclaw
  2. Install a plugin: npx -y @tencent-weixin/openclaw-weixin-cli@latest install
  3. Start openclaw gateway: openclaw gateway
  4. Observe error:
    [plugins] openclaw-weixin failed to load from C:\Users\gzsia\.openclaw\extensions\openclaw-weixin\index.ts: Error: Cannot find module 'openclaw/plugin-sdk/channel-config-schema'
    

Expected Behavior

Plugins should load correctly when openclaw is installed globally via npm.

Actual Behavior

Plugin loader's resolveLoaderPluginSdkPackageRoot() traverses upward from plugin directory (C:\Users\gzsia\.openclaw\extensions\openclaw-weixin\) to find openclaw package root. However, when openclaw is globally installed via npm, its location (C:\Users\gzsia\AppData\Roaming\npm\node_modules\openclaw) is not in any parent directory of plugin directory.

As a result:

  • resolvePluginSdkScopedAliasMap() returns an empty object {}
  • Only base "openclaw/plugin-sdk" alias (pointing to root-alias.cjs) is registered
  • Subpath aliases like "openclaw/plugin-sdk/channel-config-schema" are missing
  • Jiti fails to resolve import and throws Cannot find module

Environment

  • OS: Windows 11
  • openclaw version: 2026.3.23-2
  • Plugin: @tencent-weixin/openclaw-weixin v2.0.1

Workaround

Create a junction from plugin's node_modules to the globally installed openclaw:

New-Item -ItemType Directory -Path "C:\Users\gzsia\.openclaw\extensions\openclaw-weixin\node_modules" -Force
cmd /c mklink /J "C:\Users\gzsia\.openclaw\extensions\openclaw-weixin\node_modules\openclaw" ^
               "C:\Users\gzsia\AppData\Roaming\npm\node_modules\openclaw"

This allows Node's native module resolution to find openclaw, bypassing the broken alias mechanism.

Suggested Fix

resolveLoaderPluginSdkPackageRoot() should fall back to additional search strategies when parent traversal fails:

  1. Check process.env.PATH for npm global directories
  2. Use npm config get prefix to locate global npm installation
  3. Leverage Node's native module resolution via require.resolve('openclaw') or import.meta.resolve('openclaw')

Alternatively, allow users to explicitly specify the openclaw package root via an environment variable or configuration option.


Note: This is a cross-session bug affecting all Windows users with global openclaw installations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions