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.
default
✓ import srvx from 'vite-plugin-srvx'
✗ const srvx = require('vite-plugin-srvx')
Default import; CommonJS require may not work in ESM-only environments but plugin is primarily used in Vite config files which support both.
SrvxOptions
✓ import type { SrvxOptions } from 'vite-plugin-srvx'
TypeScript type import for options object.
loadModule
✓ import { loadModule } from 'vite-plugin-srvx'
✗ import loadModule from 'vite-plugin-srvx'
Named export for custom loadModule option; not a default export.
defineConfig
✓ import { defineConfig } from 'vite'
✗ import { defineConfig } from 'vite-plugin-srvx'
defineConfig is from Vite, not from this plugin.
Basic setup: Vite config, srvx server file, and index.html for dev with HMR.
// vite.config.ts
import { defineConfig } from 'vite'
import srvx from 'vite-plugin-srvx'
export default defineConfig({
plugins: [
...srvx({
entry: './src/server.ts',
}),
],
})
// src/server.ts
export default {
async fetch(request: Request): Promise<Response> {
const url = new URL(request.url)
if (url.pathname === '/api/hello') {
return Response.json({ message: 'Hello from srvx!', timestamp: new Date().toISOString() })
}
return new Response('Not Found', { status: 404 })
},
}
// index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My srvx App</title>
</head>
<body>
<h1>Hello from srvx + Vite!</h1>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
Errors
Common errors & fixes
Error: The plugin returned an array, but Vite expects a single plugin.
Using srvx({...}) without spread operator in plugins array.
fixUse ...srvx({...}) instead. Error: [vite] Internal server error: Failed to load module /src/server.ts
Entry file path mismatch or missing entry file.
fixCheck entry option in srvx() and ensure server file exists.
Error: Cannot find module 'srvx'
Missing srvx peer dependency.
Audit
Dependencies
srvxrequiredPeer dependency: peerDependencies specification requires srvx >=0.9.0
viterequiredPeer dependency: requires Vite ^5.0.0 || ^6.0.0