4

I'm trying to use vue-socket.io package here, so I did install it first then imported it in the app.js file, but in the Vue.use line the socketio throws a console error Uncaught ReferenceError: socketio is not defined:

npm install vue-socket.io --save

import VueSocketio from 'vue-socket.io';
Vue.use(VueSocketio, socketio('http://localhost:3000'), store);
2
  • That package appears to depend on npmjs.com/package/socket.io-client. Commented Jun 27, 2017 at 18:35
  • I think this is an alternative way to include the file using the script tag Commented Jun 27, 2017 at 18:47

1 Answer 1

4

The documentation suggests a default configuration.

import VueSocketio from 'vue-socket.io';
Vue.use(VueSocketio, 'http://socketserver.com:1923');

If you want to use the one you're using

import VueSocketio from 'vue-socket.io';
Vue.use(VueSocketio, socketio('http://localhost:3000'), store);

You're going to have to import socketio from somewhere. Your script doesn't know what that is. Looking at the source suggests that you could do this:

import VueSocketio from 'vue-socket.io';
import socketio from 'socket.io-client'

Vue.use(VueSocketio, socketio('http://localhost:3000'), store);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this makes sense. I'll give it a try

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.