2014-01-16 7 views
0

다른 클라이언트에 공유 데이터가있는 위치에 응용 프로그램을 작성하려면 AngularJs 노드 & socket.io를 사용하고 있습니다. 이 예제를 보겠습니다 : https://github.com/mhevery/angular-node-socketiolocalhost의 Angularjs + node + socket.io

내 파일 시스템 (c : /user/angularnodesocket/index.html)에서 index.html의 위치로 이동하면 모든 것이 정상적으로 작동하고 정상적으로 작동합니다. , 그러나 내가 localhost : 8888에 갈 때 사이트는 여전히 보여 주지만 각도 물건은 해석되지 않습니다.

나는

Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8888/bower_components/angular/angular.js". localhost/:4 
Uncaught SyntaxError: Unexpected token < :8888/bower_components/angular/angular.js:1 

사람이 여기에 무슨 일이 일어나고 있는지를 도와 줄 수

로컬 호스트에서이 오류가? 이 예에서 // G

답변

0

는 다음과 같은 코드 요청이 무엇이든

http.createServer(function (request, response) { 
     fs.readFile(__dirname+'/public/index.html', function (err, data) { 
       if (err) throw err; 
       response.setHeader("Content-Type", "text/html"); 
       response.end(data); 
     }); 
}).listen(8888); 

반환 된 index.html을 사용하고 있습니다. 브라우저가 angular.js 파일을 요청했지만 표시되는 오류 메시지를 유발하는 대신 색인 html이 반환됩니다.

정적 파일을 지원하려면 server.js 코드를 수정해야합니다.

관련 문제