发布

  • fix(mcp): use createRequire for @ast-grep/napi resolution

    frostbyte_neo 发布于 2026-01-28 09:52:15 +00:00

    ROOT CAUSE: Dynamic import("@ast-grep/napi") uses ESM resolution,
    which does NOT respect NODE_PATH or Module._initPaths(). Those only
    affect CJS require() calls.

    FIX: Use createRequire() to create a CJS-style require function that
    respects NODE_PATH. Falls back to dynamic import for pure ESM environments.

    The banner still sets NODE_PATH and calls _initPaths() for CJS require()
    to find the globally-installed @ast-grep/napi.

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    下载附件