2026-05-08 15:56:35 +08:00
|
|
|
# vite-plugin-port-checker
|
|
|
|
|
|
|
|
|
|
A Vite plugin that warns when the dev server listens on a port blocked by browsers (e.g. Chrome, Firefox).
|
|
|
|
|
|
|
|
|
|
Reference: [Fetch spec — port blocking](https://fetch.spec.whatwg.org/#port-blocking)
|
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-08 09:25:17 +08:00
|
|
|
npm install vite-plugin-port-checker -D
|
2026-05-08 15:56:35 +08:00
|
|
|
# or
|
2026-06-08 09:25:17 +08:00
|
|
|
pnpm add vite-plugin-port-checker -D
|
2026-05-08 15:56:35 +08:00
|
|
|
# or
|
2026-06-08 09:25:17 +08:00
|
|
|
yarn add vite-plugin-port-checker -D
|
2026-05-08 15:56:35 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
```ts
|
|
|
|
|
// vite.config.ts
|
|
|
|
|
import { defineConfig } from "vite"
|
|
|
|
|
import checkRestrictedPort from "vite-plugin-port-checker"
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [checkRestrictedPort()],
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
When the dev server starts on a restricted port, you'll see a yellow warning in the console suggesting you change `server.port`.
|
|
|
|
|
|
2026-05-08 17:59:13 +08:00
|
|
|
## Licence
|
2026-05-08 15:56:35 +08:00
|
|
|
|
|
|
|
|
MIT
|