Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import eslint from 'vite-plugin-eslint2'
✗ const eslint = require('vite-plugin-eslint2')
ESM-only. The package does not export a CommonJS version.
pluginOptions (type)
✓ import type { Options } from 'vite-plugin-eslint2'
✗ import { Options } from 'vite-plugin-eslint2'
Options is a type, not a runtime value. Use `import type` in TypeScript.
eslint (function)
✓ import eslint from 'vite-plugin-eslint2'
✗ import { eslint } from 'vite-plugin-eslint2'
The only export is a default function. Named import `{ eslint }` will fail.
Basic setup of vite-plugin-eslint2 in a Vite config with common options.
// vite.config.ts
import { defineConfig } from 'vite';
import eslint from 'vite-plugin-eslint2';
export default defineConfig({
plugins: [
eslint({
exclude: ['node_modules', 'dist'],
lintOnStart: true,
cache: true
})
]
});
Debug
Known issues
breakingIn v5.0.0, the `chokidar` option was removed. If you were relying on it for file watching, you must use Vite's built-in file watching instead.fixRemove the `chokidar` option from plugin options.
affects: >=5.0.0
breakingESLint v9+ uses flat config by default. If you upgrade from v8 to v9, your `.eslintrc` config might not work; you need to migrate to `eslint.config.js`.fixCreate an `eslint.config.js` file with flat config, or set `ESLINT_USE_FLAT_CONFIG=false` temporarily.
affects: >=4.0.0 (ESLint v9 support)
deprecatedESLint v7 and v8 are deprecated. The plugin still supports them but they are not receiving updates.fixUpgrade to ESLint v9 or later.
affects: >=0.0.0
gotchaThe plugin uses a worker thread for linting. If you use a custom `eslint` instance that is not serializable, the worker might fail.fixEnsure the `eslint` option passed to the plugin is a function that returns a new instance, not an already-created instance.
affects: >=0.0.0
Errors
Common errors & fixes
ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './eslint' is not defined by "exports"
Using an outdated import like `import eslint from 'vite-plugin-eslint2/eslint'` (assuming a subpath export).
fixUse `import eslint from 'vite-plugin-eslint2'` instead.
Cannot find module 'eslint/use-at-your-own-risk'
Trying to use a deprecated internal ESLint API (e.g., `ESLint` class from `use-at-your-own-risk`).
fixUse `import { ESLint } from 'eslint'` and pass it as a factory function in plugin options. TypeError: eslint is not a function
Importing the module as a named export (`import { eslint } from 'vite-plugin-eslint2'`) instead of default.
fixUse `import eslint from 'vite-plugin-eslint2'` (default import).
Audit
Dependencies
eslintrequiredPeer dependency; required to perform linting.
viterequiredPeer dependency; the plugin is designed to work as a Vite plugin.