Vue-Socket.io icon indicating copy to clipboard operation
Vue-Socket.io copied to clipboard

Error on Vue3 cannot set properties of undefined (setting '$socket')

Open meroo36 opened this issue 3 years ago • 7 comments

In node_modules/vue-socket.io/dist/vue-socketio.js there is a line as:

{t.prototype.$socket=this.io,t.prototype.$vueSocketIo=this,t.mixin(n),i.info("Vue-Socket.io plugin enabled")}

I just changed the line as:

{t.config.globalProperties.$socket=this.io,t.config.globalProperties.$vueSocketIo=this,t.mixin(n),i.info("Vue-Socket.io plugin enabled")}

Simply changed "t.prototype"'s to "t.config.globalProperties"'s, and it works but don't know if it is the right solution.

meroo36 avatar Nov 18 '21 12:11 meroo36

so basically no vue 3 support yet

ashantyk avatar Mar 10 '22 22:03 ashantyk

I have also had to use @meroo36 solution to prevent this error.

Rebehy avatar Jun 23 '22 04:06 Rebehy

It seems although npm says it's v3.0.10 it doesn't have the last Vue 3 fix. When installing it's probably easier to: npm i https://github.com/MetinSeylan/Vue-Socket.io.git
That works for me with Vue 3. But why isn't npm correct?

terrykingdev avatar Jul 16 '22 15:07 terrykingdev

It's August 15th, 2022, and this error still persist even with me using Vue 3. Is anyone going to update the npm entry?

devaku avatar Aug 15 '22 03:08 devaku

I got same error with Vue 3, meroo36 solution works for me too.

SeriousVitamin avatar Aug 24 '22 16:08 SeriousVitamin

Problem still present to this day on Vue 3, meroo36's solution works.

Jak3d avatar Oct 27 '23 10:10 Jak3d