{"action":"created","issue":{"url":"https://api.github.com/repos/websockets/ws/issues/662","repository_url":"https://api.github.com/repos/websockets/ws","labels_url":"https://api.github.com/repos/websockets/ws/issues/662/labels{/name}","comments_url":"https://api.github.com/repos/websockets/ws/issues/662/comments","events_url":"https://api.github.com/repos/websockets/ws/issues/662/events","html_url":"https://github.com/websockets/ws/issues/662","id":125764635,"number":662,"title":"Cannot find module \"fs\"","user":{"login":"JoeDawson","id":1009696,"avatar_url":"https://avatars.githubusercontent.com/u/1009696?v=3","gravatar_id":"","url":"https://api.github.com/users/JoeDawson","html_url":"https://github.com/JoeDawson","followers_url":"https://api.github.com/users/JoeDawson/followers","following_url":"https://api.github.com/users/JoeDawson/following{/other_user}","gists_url":"https://api.github.com/users/JoeDawson/gists{/gist_id}","starred_url":"https://api.github.com/users/JoeDawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoeDawson/subscriptions","organizations_url":"https://api.github.com/users/JoeDawson/orgs","repos_url":"https://api.github.com/users/JoeDawson/repos","events_url":"https://api.github.com/users/JoeDawson/events{/privacy}","received_events_url":"https://api.github.com/users/JoeDawson/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-01-09T15:23:40Z","updated_at":"2016-12-15T10:43:00Z","closed_at":"2016-01-09T18:44:10Z","body":"Hello,\n\nFirstly, I'm sorry if this isn't an issue related to the ws library - but I had to start somewhere.\n\nI'm currently working on a project with Vue.js - my current code looks like this.\n\n```\nimport Vue from 'vue';\n\nnew Vue({\n\n    ready: function() {\n\n        this.connect();\n\n    },\n\n    data: function() {\n        return {\n            socket: null\n        }\n    },\n\n    methods: {\n\n        /**\n         * Connect to the Pushover WebSocket in order to\n         * retrieve push notifications.\n         * \n         * @return mixed\n         */\n        connect: function() {\n\n            var WebSocket = require('ws');\n\n            this.socket = new WebSocket('wss://client.pushover.net/push:443');\n\n            this.socket.on('open', function() {\n                this.socket.send('login:' + localStorage.getItem('device_id'));\n            });\n\n            this.socket.on('message', function(data) {\n                console.log(data);\n\n                alert('got a message');\n            });\n\n        }\n\n    },\n\n});\n```\n\nWhen the `connect` method is called, I get the following error in my console.\n\n> Uncaught Error: Cannot find module \"fs\"\n\nDo you have any idea why I might be receiving this? I know everything but the code within my `connect` method is ok as I've tested this.\n\nI hope you can help!\n"},"comment":{"url":"https://api.github.com/repos/websockets/ws/issues/comments/267296840","html_url":"https://github.com/websockets/ws/issues/662#issuecomment-267296840","issue_url":"https://api.github.com/repos/websockets/ws/issues/662","id":267296840,"user":{"login":"Vastness","id":19588557,"avatar_url":"https://avatars.githubusercontent.com/u/19588557?v=3","gravatar_id":"","url":"https://api.github.com/users/Vastness","html_url":"https://github.com/Vastness","followers_url":"https://api.github.com/users/Vastness/followers","following_url":"https://api.github.com/users/Vastness/following{/other_user}","gists_url":"https://api.github.com/users/Vastness/gists{/gist_id}","starred_url":"https://api.github.com/users/Vastness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vastness/subscriptions","organizations_url":"https://api.github.com/users/Vastness/orgs","repos_url":"https://api.github.com/users/Vastness/repos","events_url":"https://api.github.com/users/Vastness/events{/privacy}","received_events_url":"https://api.github.com/users/Vastness/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T10:43:00Z","updated_at":"2016-12-15T10:43:00Z","body":"I'm new to ws,and I just got the same problem today.\r\nThen I follow the solution as @xxd3vin says,however, I got an new problem as \r\n[http://stackoverflow.com/questions/29829597/i-get-a-status-200-when-connecting-to-the-websocket-but-it-is-an-error#](url) mentioned.\r\nThus, I realized there is something seriously wrong with how we are using the code.\r\n\r\n> In the browser, you are using the native WebSocket class and not SockJS !\r\n\r\nSo, we should just remove `var WebSocket = require('ws');` and change the url to `var ws = new WebSocket(yourhost+'/websocket')` in the client side js. Finally, solve the problem perfectly."}}
{"actor":{"display_login":"Vastness"}}