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–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
watch
✓ import { watch } from 'vite-plugin-watch'
✗ import watch from 'vite-plugin-watch'
Named export, not default.
WatchPluginOptions
✓ import type { WatchPluginOptions } from 'vite-plugin-watch'
✗ import { WatchPluginOptions } from 'vite-plugin-watch'
TypeScript type import.
watch (CommonJS)
✓ const { watch } = require('vite-plugin-watch')
✗ const watch = require('vite-plugin-watch')
Use destructuring, not default assignment.
Configures vite-plugin-watch to run `npm run build:css` whenever any .scss file in src/ changes. Uses 1s debounce, shows output, runs on start.
// vite.config.js
import { defineConfig } from 'vite';
import { watch } from 'vite-plugin-watch';
export default defineConfig({
plugins: [
watch({
pattern: 'src/**/*.scss',
command: 'npm run build:css',
timeout: 1000,
silent: false,
onInit: true
})
]
});
Debug
Known issues
gotchaThe `command` can be a string or an array of strings. If an array, each command runs sequentially.fixFor sequential commands, use array: `command: ['echo first', 'echo second']`.
affects: >=0.0.0
deprecatedNo deprecated features known.
breakingNo known breaking changes between versions.
Errors
Common errors & fixes
Unexpected token 'export'
Using require() in a CommonJS file without proper destructuring or using ESM syntax in a CJS context.
fixUse `const { watch } = require('vite-plugin-watch')` or switch to ESM. Cannot find module 'vite-plugin-watch'
Package not installed or missing from package.json.
fixRun `npm i -D vite-plugin-watch` to install as dev dependency.
TypeError: watch is not a function
Default import instead of named import.
fixUse `import { watch } from 'vite-plugin-watch'`. Audit
Dependencies
No dependency data recorded yet.