Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
KubbPlugin
✓ import { KubbPlugin } from 'unplugin-kubb'
✗ const { KubbPlugin } = require('unplugin-kubb')
ESM-only since v5; requires Node>=20. Named export.
default
✓ import KubbPlugin from 'unplugin-kubb'
✗ const KubbPlugin = require('unplugin-kubb')
Default export alias for KubbPlugin. Same as named export.
type KubbPluginOptions
✓ import type { KubbPluginOptions } from 'unplugin-kubb'
Type export for TypeScript users.
createKubbPlugin
✓ import { createKubbPlugin } from 'unplugin-kubb'
✗ import { CreateKubbPlugin } from 'unplugin-kubb'
Factory function; not a class. Lowercase 'c'.
Shows how to integrate Kubb into a Vite project using the unplugin-kubb plugin with an OpenAPI spec.
import { defineConfig } from 'vite';
import KubbPlugin from 'unplugin-kubb';
export default defineConfig({
plugins: [
KubbPlugin({
input: {
path: './openapi.yaml',
},
output: {
path: './src/generated',
},
// Optional: specify additional plugins
plugins: ['@kubb/swagger-ts', '@kubb/swagger-client'],
}),
],
});
Debug
Known issues
breakingESM-only since v5: CommonJS require() not supported.fixSwitch to ESM imports and set `"type": "module"` in package.json.
affects: >=5.0.0
breakingMinimum Node version raised to 20 in v5.fixUpgrade Node.js to >=20.
affects: >=5.0.0
gotchaPlugin must be placed before other plugins that transform output files.fixPlace KubbPlugin early in the plugins array to ensure generated files are available.
affects: *
gotchaDependency on @kubb/core version ^4.0.0 may cause peer dependency conflicts if using Kubb v5 alpha.fixEnsure all Kubb packages are on the same version range.
affects: 5.0.0-alpha.x
deprecatedThe `input` option `path` is deprecated in favor of `input.url` in v5 alpha.fixUse `input.url` instead of `input.path`.
affects: >=5.0.0-alpha.70
Errors
Common errors & fixes
Cannot find module 'unplugin-kubb' or its corresponding type declarations.
Package not installed or missing TypeScript declaration.
fixRun `npm install unplugin-kubb @kubb/core` and ensure tsconfig includes node_modules.
TypeError: KubbPlugin is not a function
Using default import with require() or wrong import statement.
fixUse `import KubbPlugin from 'unplugin-kubb'` (ESM).
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported.
CommonJS require() used with ESM-only package.
fixSwitch to `import` syntax or use dynamic import().
Uncaught TypeError: Cannot read properties of undefined (reading 'path')
Missing or incorrectly configured `input` option.
fixProvide `input` object with `path` or `url` property.
Audit
Dependencies
@kubb/corerequiredCore Kubb library for code generation logic
viteoptionalRequired for Vite integration
rollupoptionalRequired for Rollup integration
esbuildoptionalRequired for esbuild integration
webpackoptionalRequired for Webpack integration
@nuxt/kitoptionalRequired for Nuxt integration
@farmfe/coreoptionalRequired for Farm integration