Skip to content

DOCXKIT_MANIFEST_INVALID: 插件清单无效 ​

清单字段、版本范围或入口路径无效。

修复步骤 ​

  1. 修正消息指出的字段。
  2. 使用非空字符串、有效 semver,以及以 ./ 开头的安全相对路径。
  3. 确保入口位于插件包内。

问题示例 ​

ts
import { validateManifest } from 'docx-kit'

const manifest = {
  name: 'example-plugin', version: '1.0.0', docxKit: '^0.7.0',
  main: './dist/index.js', plugin: { name: 'example' },
}

validateManifest({ ...manifest, main: '../outside.js' })

修复示例 ​

ts
import { validateManifest } from 'docx-kit'

const manifest = {
  name: 'example-plugin', version: '1.0.0', docxKit: '^0.7.0',
  main: './dist/index.js', plugin: { name: 'example' },
}

validateManifest(manifest)

常见原因 ​

  • 必填字段缺失、版本范围格式不正确,或路径越过包边界。

诊断字段 ​

消息示例 ​

text
Plugin manifest field "main" must be a safe relative path beginning with "./"

源码与相关指南 ​

Released under the MIT License.