Describe the bug
First of all, I am aware the documentation uses pnpm, but in my project I'm still using npm. It's a huge project, with hundreds of transitive dependencies in total. I'm not ready to change from npm to anything else, and not ready to untangle and update all the dependency graph. (Which is something I want to do, but will take time.)
What did I do?
- Updated to vite 8. This includes
npm install.
- Added
"@vitejs/devtools": "0.1.13" to devDependencies. And, of course npm install.
- Tried enabling vite devtools. The same problem happens on both Standalone and Embedded modes.
What happens?
error when starting dev server:
file:///…/my-project-home/node_modules/@vitejs/devtools-rpc/dist/presets/ws/server.mjs:4
import { WebSocketServer } from "ws";
^^^^^^^^^^^^^^^
SyntaxError: The requested module 'ws' does not provide an export named 'WebSocketServer'
Why?
Inside ./node_modules/@vitejs/devtools-rpc/, I can see version 0.1.13 is installed, and I can see its package.json has:
"peerDependencies": {
"ws": "*"
},
"peerDependenciesMeta": {
"ws": {
"optional": true
}
},
"devDependencies": {
"tsdown": "^0.21.7",
"ws": "^8.20.0"
},
Then, at ./node_modules/ws/package.json, I see that version 7.5.0 is installed, likely as dependency of @web/dev-server-core-0.7.2, which is pulled as part of the dependency tree of @web/test-runner-0.20.2.
Thus, Vite devtools fails to start because it assumes there will be a newer version of ws pulled in by some other dependency. But since this is false, it tries to load an older version and it barfs.
Possible solution
Not having ws as peer dependency may solve this corner case. But I'm not familiar with all the implications of that. I trust you will be able to find a solution.
Alternatively, my own solution will be to upgrade several dependencies from my own package-lock.json. But will take some effort, given it has 18500 lines and over 800 directories directly child of ./node_modules/. It needs to be done carefully, making sure nothing will break due to these updates.
Reproduction
https://github.com/denilsonsa/minimal-repro-vite-devtools
System Info
System:
OS: macOS 26.4
CPU: (12) arm64 Apple M3 Pro
Memory: 2.57 GB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.14.1 - /Users/…/.homebrew/opt/node@24/bin/node
npm: 11.11.0 - /Users/…/.homebrew/opt/node@24/bin/npm
Deno: 2.7.11 - /Users/…/.homebrew/bin/deno
Browsers:
Chrome: 146.0.7680.178
Edge: 146.0.3856.97
Firefox: 149.0
Safari: 26.4
Used Package Manager
npm
Validations
Describe the bug
First of all, I am aware the documentation uses
pnpm, but in my project I'm still usingnpm. It's a huge project, with hundreds of transitive dependencies in total. I'm not ready to change fromnpmto anything else, and not ready to untangle and update all the dependency graph. (Which is something I want to do, but will take time.)What did I do?
npm install."@vitejs/devtools": "0.1.13"todevDependencies. And, of coursenpm install.What happens?
Why?
Inside
./node_modules/@vitejs/devtools-rpc/, I can see version0.1.13is installed, and I can see itspackage.jsonhas:Then, at
./node_modules/ws/package.json, I see that version7.5.0is installed, likely as dependency of@web/dev-server-core-0.7.2, which is pulled as part of the dependency tree of@web/test-runner-0.20.2.Thus, Vite devtools fails to start because it assumes there will be a newer version of
wspulled in by some other dependency. But since this is false, it tries to load an older version and it barfs.Possible solution
Not having
wsas peer dependency may solve this corner case. But I'm not familiar with all the implications of that. I trust you will be able to find a solution.Alternatively, my own solution will be to upgrade several dependencies from my own
package-lock.json. But will take some effort, given it has 18500 lines and over 800 directories directly child of./node_modules/. It needs to be done carefully, making sure nothing will break due to these updates.Reproduction
https://github.com/denilsonsa/minimal-repro-vite-devtools
System Info
System: OS: macOS 26.4 CPU: (12) arm64 Apple M3 Pro Memory: 2.57 GB / 36.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.14.1 - /Users/…/.homebrew/opt/node@24/bin/node npm: 11.11.0 - /Users/…/.homebrew/opt/node@24/bin/npm Deno: 2.7.11 - /Users/…/.homebrew/bin/deno Browsers: Chrome: 146.0.7680.178 Edge: 146.0.3856.97 Firefox: 149.0 Safari: 26.4Used Package Manager
npm
Validations