TypeError: server.ws.on is not a function

So I was upgrading a few scenes in a demo project and I used the Export Info context menu > Update Vite Config for them all, all worked except this one and it even repros in a bug report project. I’m stumped as to what is causing this as the Vite config of the original was just the basic one untouched and it is a simple project.

On run of local server I get the error: TypeError: server.ws.on is not a function

Project attached

Full error:

> my-project@1.0.0 start
> vite --host
error when starting dev server:
TypeError: server.ws.on is not a function
    at Object.configureServer (file:///C:/Unity_Projects/NeedleWebDemos/Library/PackageCache/com.needle.engine@2.58.4-pre/package~/plugins/vite/poster.js:19:23)
    at createServer (C:\Unity_Projects\NeedleWebDemos\Needle\####projectname\node_modules\vite\dist\node\chunks\dep-3e244802.js:66749:41)
    at async CAC.<anonymous> (C:\Unity_Projects\NeedleWebDemos\Needle\####projectname\node_modules\vite\dist\node\cli.js:687:24)

Original Post on Discord

by user 103054507105067008

Which vite version is installed in this project?

Make sure its using vite 3 if you update the config

“vite”: “2.6.4”

by user 103054507105067008

That will be it then, trying now

by user 103054507105067008

Then that’s expected

Yes :slightly_smiling_face:

If the Vite config updater removes lots of my stuff and resets the vite config already, can it automatically set the correct Vite version to avoid this?

by user 103054507105067008

Mmmh I’m a bit hesitant to add more responsibility to that little updater ^^

That’s alright, at least I know what caused this, when does that vite package get updated in the package.json by Needle as this was just one scene out of 10 that randomly had an old vite there

by user 103054507105067008

Yes it was vite 2 when we started with beta and I dont think many people using old projects use that menu item :slightly_smiling_face:

We updated to vite 3 around autumn 2022

It was one of my first ever test scenes which explains

by user 103054507105067008