Looks like the module that you are using is for the server-side and not the client-side socket.io lib you need. Use the client site script instead.
You can just use the <script> tag in your HTML index.html and import the socket.io js file for the client site
Your WS path looks good to me it may an issue on the server side.
Here's how I build the WS URL on the client side to run on local and Heroku:
const wsUrl = (window.location.protocol === 'http:' ? 'ws://' : 'wss://') + window.location.host;