Skip to content

[Bug] CLI/独立运行加载编译产物崩溃:TypeError: Invalid URL (ERR_INVALID_URL) #24

Description

@zzzzzmant

环境

  • OS: Windows
  • Godot: 4.6.3 stable official
  • Gode: 2.3.3

现象

  • 编辑器运行(F6 运行 res://scenes/probe_fs.tscn):✅ 正常,无报错
  • 命令行独立运行:❌ Gode compile error: TypeError: Invalid URL,随后进程卡死(反复重试编译、不退出)

复现(附件是最小复现项目,需自行把 gode 2.3.3 放入 addons/gode)

  1. 解压附件,安装插件到 addons/gode
  2. 命令行运行:
    godot --headless --path <项目路径> res://scenes/probe_fs.tscn
  3. 预期 stderr 输出:
    Gode compile error: TypeError: Invalid URL
        at new URL (node:internal/url:846:20)
        at pathToFileURL (node:internal/url:1690:10)
        at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:263:17)
        at loadESMFromCJS (node:internal/modules/cjs/loader:1690:24)
        at Module._compile (node:internal/modules/cjs/loader:1853:5)
        at globalThis.__gode_compile (...)
      code: 'ERR_INVALID_URL',
      input: 'user://.gode/typescript/<hash>/typescript-6.0.3/scripts/probe_fs.js'
    

关键发现

  • 触发文件 scripts/probe_fs.ts 不含任何 npm 导入,与 npm 无关
  • 炸点在独立运行加载编译产物:__gode_compile → Node require(esm) 桥接 → pathToFileURL("user://...")ERR_INVALID_URL
  • 编辑器模式正常,独立运行(CLI / 导出)路径崩溃
  • 对照组:scripts/probe_blank.ts 在 CLI 下可正常输出 PROBE-BLANK-OK;但 gode 是全项目编译,只要 probe_fs.ts 存在,CLI 下任何场景都会崩

gode-repro.zip

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