Skip to content

DOCXKIT_UNKNOWN_NODE_TYPE: 节点类型无法编译 ​

当前上下文没有支持此节点的编译器。

修复步骤 ​

  1. 使用文档列出的 DSL 类型。
  2. 自定义内容使用已注册的 plugin 节点。
  3. sectionBreak 放在文档层级,不要嵌套在子内容中。

问题示例 ​

ts
// Invalid DSL fragment:
const node = { type: 'paragaph', text: 'Hello' }

修复示例 ​

ts
import { renderDocx } from 'docx-kit'

const doc = await renderDocx({
  content: [{ type: 'paragraph', text: 'Hello' }],
})
const blob = await doc.toBlob()

常见原因 ​

  • 节点类型拼写错误、行内内容使用了块节点,或分节节点位置不正确。

诊断字段 ​

消息示例 ​

text
Unknown node type: unknown

源码与相关指南 ​

Released under the MIT License.