Skip to content

DOCXKIT_EXPORT_FAILED: 文档导出失败 ​

编译后的文档打包失败,调用方仍可读取原始 cause。

修复步骤 ​

  1. 在本地检查 error.cause,定位失败资源。
  2. 使用当前平台支持的导出格式,并确认引用资源有效。

问题示例 ​

ts
// Packaging can fail when a referenced resource is invalid.
// Inspect the original cause at the export boundary.

修复示例 ​

ts
import { createDocx, DocxKitError, serializeDocxKitError } from 'docx-kit'

try {
  const blob = await createDocx().p('Hello').toBlob()
} catch (error) {
  if (error instanceof DocxKitError) {
    console.error(serializeDocxKitError(error))
    // Inspect error.cause locally when needed.
  } else {
    throw error
  }
}

常见原因 ​

  • 文档资源无效,或底层打包过程失败。

诊断字段 ​

消息示例 ​

text
Failed to pack document to blob

源码与相关指南 ​

Released under the MIT License.