Skip to content

DTK0014: Plugin Setup Error ​

Message ​

Error setting up plugin {name}

Cause ​

This error is thrown by createDevToolsContext() when a Vite plugin's devtools.setup() hook throws during initialization. The DevTools context iterates over all Vite plugins that define a devtools property and calls their setup() hook with the ViteDevToolsNodeContext. If the hook throws, the error is caught, wrapped with this diagnostic (preserving the original error as cause), and re-thrown -- halting DevTools initialization.

Plugins may be skipped entirely if their devtools.capabilities configuration indicates they do not support the current mode (dev or build).

Example ​

A plugin with a failing setup hook:

ts
// my-vite-plugin.ts
import type { Plugin } from 'vite'

export default function myPlugin(): Plugin {
  return {
    name: 'my-plugin',
    devtools: {
      setup(context) {
        // This error triggers DTK0014 with name "my-plugin"
        throw new Error('Failed to connect to analysis service')
      },
    },
  }
}
ts
import devtools from '@vitejs/devtools'
// vite.config.ts
import { defineConfig } from 'vite'
import myPlugin from './my-vite-plugin'

export default defineConfig({
  plugins: [
    devtools(),
    myPlugin(),
  ],
})

Running vite dev will throw:

Error setting up plugin my-plugin
  Caused by: Failed to connect to analysis service

Fix ​

  1. Check the cause attached to the diagnostic for the original error and stack trace.
  2. Fix the issue in your plugin's devtools.setup() hook. Common causes include:
    • Missing dependencies or services the plugin relies on.
    • Invalid configuration passed to the plugin.
    • Errors in dock/RPC registration during setup.
  3. Add error handling in your setup hook for non-critical operations:
ts
export default function myPlugin(): Plugin {
  return {
    name: 'my-plugin',
    devtools: {
      async setup(context) {
        // Guard non-critical initialization
        try {
          await connectToService()
        }
        catch {
          console.warn('Analysis service unavailable, some features disabled')
        }

        // Critical registrations
        context.docks.register({
          id: 'my-plugin:dashboard',
          type: 'iframe',
          title: 'My Plugin',
          icon: 'ph:chart-bar-duotone',
          category: 'analysis',
          src: '/__my-plugin/',
        })
      },
    },
  }
}

Source ​

  • packages/core/src/node/context.ts — createDevToolsContext() wraps each plugin's devtools.setup() invocation; throws DTK0014 (with the original error as cause) when the hook fails.

Released under the MIT License.