for an assignment, I've created a chat app with Socket.io. I was able to create a functioning chat by following this tutorial: https://www.youtube.com/watch?v=tHbCkikFfDE. However, the assignment gave me a specific chat server to use and I am struggling to do so. I am trying to import io and then use the io.connect() method to connect to the server url. The problem is, when I try to import, I get a "SyntaxError: Unexpected identifier".
This is my code up until that line:
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
var users = [];
var connections = [];
import io from "socket.io-client";
The last line, 'import io from "socket.io-client";', produces the error with the carets pointing specifically to the "io" part of the statement. Any ideas on what the issue might be or suggestions for alternative approaches? If it wasn't already clear, I'm quite inexperienced with JavaScript and might not be tackling the problem in the best way.