Vue-Socket.io
Vue-Socket.io copied to clipboard
Error on Vue3 cannot set properties of undefined (setting '$socket')
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.
so basically no vue 3 support yet
I have also had to use @meroo36 solution to prevent this error.
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?
It's August 15th, 2022, and this error still persist even with me using Vue 3. Is anyone going to update the npm entry?
I got same error with Vue 3, meroo36 solution works for me too.
Problem still present to this day on Vue 3, meroo36's solution works.