Skip to content

[Bug] @memtensor/memos-lite-openclaw-plugin v0.2.3 fails to load: ReferenceError: exports is not defined in ES module scope #1733

@hong20260515

Description

@hong20260515

问题描述

@memtensor/memos-lite-openclaw-plugin v0.2.3 安装后在 OpenClaw 2026.5.7 上加载失败。

错误信息

[plugins] memos-local-openclaw-plugin failed to load from .../dist/index.js:
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension
and package.json contains "type": "module". To treat it as a CommonJS script,
rename it to use the '.cjs' file extension.

原因分析

  • package.json 中声明了 "type": "module"(ES Module 模式)
  • dist/index.js 使用的是 CommonJS 语法:exports.initPlugin = initPlugin + require()
  • Node.js 22.x 严格按 package.jsontype 字段判断模块格式,导致加载失败

环境

  • OS: Linux 6.17.0-23-generic (Ubuntu 24.04)
  • Node: v22.22.2
  • OpenClaw: 2026.5.7
  • Plugin: @memtensor/memos-lite-openclaw-plugin v0.2.3 (manifest id: memos-local-openclaw-plugin)

尝试过的修复

  1. dist/index.jsdist/index.cjs,同时更新 openclaw.plugin.json 指向 ./dist/index.cjs
    • 但其他依赖文件(config.js, telemetry.js, types.js)也存在同样问题
    • 全部改为 .cjs 后仍加载失败
  2. better-sqlite3 在安装时已成功编译

建议修复方向

  • package.json 中移除 "type": "module",或
  • 将 dist 目录的所有 .js 文件改为 .cjs 并更新入口配置,或
  • dist/index.js 从 CommonJS exports 重构为 ESM export 语法

感谢!期待修复 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions