###前提・実現したいこと
Node.jsとsocket.ioを用いて双方向通信を行いたいと考えています。
その中で以下を参考にチュートリアルをしています。
ドットインストール:socket.io入門
###発生している問題・エラーメッセージ
下記問題が発生していますが、原因と対処方法が調べてもわからないです。
1./socket.io/socket.io.jsが生成されないが、読み込みなどされているのでしょうか。
・様々な参考を見るとsocketioを読み込んだ場合上記jsファイルが自動生成されると
ありましたが、生成されません。
また、参考動画ではapp.jsを起動すると
info -socket.io started
が出力されていましたが、この文字列も出力されません。
なぜ上手く読み込まないのかがわかりません、どのようにすれば読み込み成功するのでしょうか。
2.上記index.htmlを実行すると下記エラーが出力される。
chromeのコンソールに下記メッセージが出力されますが理由がわかりません。
下記参考を見てもxmlの同時実行などしてないはずなのにも関わらずなぜ出力されるのでしょうか。
参考1
参考2
Deprecation] Synchronous XMLHttpRequest on the ctouch_bootstrap.js:22 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check
GET filesystem:chrome-extension://iemofinbkpbpamdjl ctouch_bootstrap.js:23 GET filesystem:chrome-extension://iemofinbkpbpamdjljafoheiaamajgdn/persistent/ctouch_filesystem.json
Uncaught DOMException: Failed to execute 'send' on ctouch_bootstrap.js:23 Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'filesystem:chrome-extension://iemofinbkpbpamdjljafoheiaamajgdn/persistent/ctouch_filesystem.json'. at getFile (chrome-extension://iemofinbkpbpamdjljafoheiaamajgdn/ctouch_bootstrap.js:23:7) at chrome-extension://iemofinbkpbpamdjljafoheiaamajgdn/ctouch_bootstrap.js:26:30 at chrome-extension://iemofinbkpbpamdjljafoheiaamajgdn/ctouch_bootstrap.js:384:3
###該当のソースコード
app.js
javascript
1var app = require('http').createServer(handler), 2 io = require('socket.io').listen(app), 3 fs = require('fs'); 4app.listen(1337); 5function handler (req,res){ 6 fs.readFile(__dirname+'/index.html',function(err,data){ 7 if(err){ 8 res.writeHead(500); 9 return res.end('Error'); 10 } 11 res.writeHead(200); 12 res.write(data); 13 res.end(); 14 }) 15}
index.html
html
1<!doctype html> 2<html lang="ja"> 3<head> 4<meta charset="utf-8"> 5<title>socketio練習</title> 6</head> 7<body> 8<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 9<script src = "/socket.io/socket.io.js"></script> 10<script> 11</script> 12</body> 13</html> 14
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/04 22:15
2017/06/05 01:56
2017/06/05 12:38