본문 바로가기

웹서버 구동

[Node.js] 웹소켓 Socket.io 설치 후 인식안될때 npm install -g socket.io 입력하여 간단히 소켓을 설치했습니다. ㅎㅎ Socket.io 설치 후 예제 작성하여 실행하였는데.. 헐. D:\>cd nd D:\nd>node server.js module.js:340 throw err; ^ Error: Cannot find module 'socket.io' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (D:\nd\server.js:2:10) at Module._compile.. 더보기
[Node.js] express 생성 코드 참고 참고한 블로그 express 프로젝트_폴더명 하면 간단하게 익스프레스 기본 껍대기가 생기게 됩니다. 자동 생성된 파일 중 app.js 을 node 명령어로 실행하구요. 그 파일 내용 은 아래와 같습니다. /** * Module dependencies. */ var express = require('express'); var routes = require('./routes'); var user = require('./routes/user'); var http = require('http'); var path = require('path'); var app = express(); // all environments app.set('port', process.env.PORT || 3000); app.set('.. 더보기
[Node.js] 기본 모듈 설명 (자주 사용되는것들) 자세한 내용 참고 기본 모듈의 형태나 사용방법은 유닉스환경과 유사한부분이 있어 관련 개발경험이 있을경우 접근이 용이한 장점을 가지고있습니다. Globals - 전역 객체 (보통 생략하고 씁니다) File System - 파일 시스템 관련 모듈로서 파일 읽기, 쓰기, 수정, 권한 등을 담당 'fs' Path - 파일 및 디렉토리의 경로와 관련된 모듈 'path' HTTP/HTTPS - HTTP 서버와 클라이언트 구현 관련 모듈 'http' Debugger - 노드를 디버깅하기 위한 모듈 더보기
Node.js 로 컴퓨터에서 웹서버 생성 및 구동 시켜보기 참고블로그 NPM (Node Package Manager) Node.js 관련 Node.js 설치하기 Node.js REPL 사용하여 콘솔 로그 Hello World 찍어보기 설치 관련 링크 설치까지는 이전글을 참고하시면 되고 설치이후부터 진행입니다. 1. js파일 생성 아래와 같은 스크립트를 작성하여 *.js 파일로 저장합니다. 파일명 띄어쓰기 허용하지 않습니다. var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World~!\n'); }).listen(8888); console... 더보기