Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
meroo36 opened this issue Nov 18, 2021 · 7 comments
Open

Comments

@meroo36
Copy link

meroo36 commented Nov 18, 2021

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.

@ashantyk
Copy link

so basically no vue 3 support yet

@Rebehy
Copy link

Rebehy commented Jun 23, 2022

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

@terrykingdev
Copy link

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?

@devaku
Copy link

devaku commented Aug 15, 2022

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

@SeriousVitamin
Copy link

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

@Jak3d
Copy link

Jak3d commented Oct 27, 2023

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

@narenkram
Copy link

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 works, thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants