Node.js 문서 원본 보기
←
Node.js
둘러보기로 가기
검색하러 가기
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다:
사용자
.
이 문서는 편집하거나 다른 명령을 할 수 없도록 보호되어 있습니다.
문서의 원본을 보거나 복사할 수 있습니다.
Server Side JavaScript인 Node.js를 정리 합니다. *홈페이지 : [http://nodejs.org/ http://nodejs.org/] **[http://nodejs.sideeffect.kr/docs/ http://nodejs.sideeffect.kr/docs/] *다운로드 : [http://nodejs.org/download/ http://nodejs.org/download/] *라이선스 : *플랫폼 : [[JavaScript|JavaScript]] == Node.js 개요 == Node.js는 서버사이드 자바스크립트이며 Google의 자바스크립트 엔진인 V8이 빌트인되어 있습니다. Event 기반이며 non-blocking I/O를 지원합니다. 자바스크립트의 표준라이브러리 프로젝트인 [http://commonjs.org/ CommonJS]의모듈시스템을 지원합니다. *Event loop 방식 :*동작 요청시 동작이 완료될 경우에 실행될 Call Back을 지정하는 방식 == Node.js 설치 == === CentOS에서 설치 === yum install nodejs npm === Windows에서 설치 === [http://nodejs.org/download/ 다운로드 사이트]에서 node-v0.12.0-x64.msi 파일을 다운로드 하여 설치 합니다. == Node.js 문법 == === Node.js 기초 === === 내장 상수 === === 내장 함수와 특수 함수 === === 상수/변수 선언 === === 객체 선언 === === 연산자 === === 조건문/반복문 === === 오류 처리 === === 기타 문법 === === Type 변환 === == 입출력 == === 전역 변수 === === 브라우저 입출력 === === Cookie 입출력 === === 세션 입출력 === === 데이터베이스 입출력 === === 파일 입출력 === === 이메일 입출력 === === Command Line 입출력 === == 유용한 Node.js 모듈 == == Console == node 명령을 사용하여 node Console을 실행할 수 있습니다. 종료시에는 process.exit(0); 또는 Ctrl_C + Ctrl_C를 눌러 줍니다. == Package 관리 == modbus 폴더를 만들고 jsmodbus 모듈을 설치 한다. mkdir -p /work/appl/modbus cd /work/appl/modbus npm init #--- scada_modbus, 0.0.1, Modbus for SCADA, scada.js, 엔터, 엔터, 엔터, OBCon, 엔터, yes This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg> --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (modbus) scada_modbus version: (1.0.0) 0.0.1 description: Modbus for SCADA entry point: (index.js) scada.js test command: git repository: keywords: author: OBCon license: (ISC) About to write to /work/appl/modbus/package.json: { "name": "scada_modbus", "version": "0.0.1", "description": "Modbus for SCADA", "main": "scada.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "OBCon", "license": "ISC" } Is this ok? (yes) yes # npm install [모듈명] --save #--- 모듈 설치후 package.json 파일에 추가 npm install jsmodbus --save #--- 3.1.0 npm install -g mocha #--- 5.2.0 npm install -g sinon #--- 6.3.3 npm 주요 명령 npm init : 패키지 관리 설정 파일인 package.json 파일을 생성 한다. npm install [모듈명] --save : 모듈을 설치하고 package.json 파일에 반영 한다. npm install [모듈명] --save-dev : 모듈을 설치하고 package.json 파일의 개발용 모듈에 반영 한다. npm install : package.json 파일을 참조하여 필요한 모듈을 설치 한다. npm install -g 전역 설치 : CLI로 사용 # npm init #--- 패키지 관리 설정 파일인 package.json 파일을 생성 한다. # npm install jsmodbus --save #--- jsmodbus 3.1.0 설치 vi package.json { "name": "scada_modbus", "version": "0.0.1", "keywords": [ "SCADA", "Modbus" ], "description": "Modbus for SCADA", "main": "scada.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "OBCon Inc.", "license": "Copyright OBCon Inc. All right reserved.", "dependencies": { "jsmodbus": "^3.1.0" }, "devDependencies": {} } npm install #--- package.json 파일로 설치를 시작 한다. npm update npm install -g mocha #--- mocha 5.2.0 전역 설치 npm install -g sinon #--- sinon 6.3.3 전역 설치 npm list #--- 설치된 모듈 목록 조회 npm list -g --depth=0 #--- 전역 설치된 모듈 목록 조회 npm uninstall ~ npm uninstall ~ --save|--save-dev npm version major #--- Major 버전을 올립니다. npm version minor #--- Minor 버전을 올립니다. npm version patch #--- Patch 버전을 올립니다. 참고 문헌 * https://heropy.blog/2018/02/18/node-js-npm/ == Test Framework == <span style="color:#008000;"><span style="font-size:larger;">테스트 방식</span></span> *TDD (Test-Driven Development) : 테스트 자체에 집중 *BDD (Behaviour-Driven Development) : 비즈니스 요구 사항에 집중 <span style="color:#008000;"><span style="font-size:larger;">Karma 모듈을 설치 합니다.</span></span> *설정 파일 : karma.conf.js, test-main.js *테스트 모듈 실행 : karma start karma-conf.js npm install karma-cli -g<br/>npm install karma -g --save-dev<br/>npm install karma-coverage --save-dev<br/>npm install karma-jasmine --save-dev<br/># npm install karma-chrome-launcher --save-dev<br/>karma --version karma init karma.conf.js<br/># Which testing framework do you want to use ? jasmine<br/># Do you want to use Require.js ? yes<br/># Do you want to capture any browsers automatically ? Chrome<br/># What is the location of your source and test files ?<br/># Should any of the files included by the previous patterns be excluded ?<br/># Do you wanna generate a bootstrap file for RequireJS? yes<br/># Do you want Karma to watch all the files and run the tests on change ? yes 환경 변수 설정 : CHROME_BIN = chrome.exe <span style="color: rgb(0, 128, 0); font-size: 15.6000003814697px; line-height: 24.9600009918213px;">Jasmine 모듈을 설치 합니다.</span> *설정 파일 : spec/support/jasmine.json *테스트 모듈 실행 **js/sample.js, test/sampleSpec.js **모든 Test 프로그램은 ~Spec.js 형태로 작성하여야 합니다. **jasmine-node --test-dir test --color --verbose **jasmine-node --test-dir test --autotest --watch test --color npm install jasmine -g<br/>jasmine init npm install jasmine-node -g<br/>jasmine-node --version <br/>참고 문헌 *Karma **[http://programmingsummaries.tistory.com/327 http://programmingsummaries.tistory.com/327] **[http://mobicon.tistory.com/407 http://mobicon.tistory.com/407] **[http://webframeworks.kr/tutorials/angularjs/angularjs_unit_test/ http://webframeworks.kr/tutorials/angularjs/angularjs_unit_test/] *Mocha **[http://blog.outsider.ne.kr/770 http://blog.outsider.ne.kr/770] **[http://unitjs.com/guide/mocha.html http://unitjs.com/guide/mocha.html] *Supertest **[http://hatemogi.com/holiday-project-day-03/ http://hatemogi.com/holiday-project-day-03/] *[http://blog.outsider.ne.kr/1078 http://blog.outsider.ne.kr/1078] *[http://required.cafe24.com/blog/2014/05/hello-karmajs/ http://required.cafe24.com/blog/2014/05/hello-karmajs/] == 참고 문헌 == *[http://blog.grotesq.com/post/448 Apahce, Nginx를 node.js의 프록시로 연결하기, 2014.04] *[http://pyrasis.com/nodejs/nodejs-HOWTO http://pyrasis.com/nodejs/nodejs-HOWTO] *[http://bcho.tistory.com/tag/node.js http://bcho.tistory.com/tag/node.js] *[[Nginx|Nginx]] *[http://crazia.tistory.com/955 Node.js: 완벽 튜토리얼 정리, 2012.11] *[http://nodejs-kr.org/insidejs/archives/670 Node.js를 활용하여 웹페이지 긁어오기., 2011.12] [[Category:JavaScript|Category:JavaScript]]
Node.js
문서로 돌아갑니다.
둘러보기 메뉴
개인 도구
로그인
이름공간
문서
토론
변수
보기
읽기
원본 보기
역사 보기
더 보기
검색
주요 메뉴
오픈소스 컨설팅
오픈소스
오픈소스 라이선스
오픈소스 커뮤니티
오픈소스 종류
오픈소스 현황
오픈소스 한글화
문자셋과 인코딩
Storage
Network
보안
고가용성
모니터링
오픈 API
오픈 서비스
Cloud
BigData
Android
산사랑 노트
둘러보기
인기 문서
최근 수정 문서
모든 문서
모든 분류
임의 문서
위키 사용법
자매 사이트
CMS
오비컨 홈페이지
오비컨 CMS
블로그
데모 - SuiteCRM
산사랑의 Twitter
산사랑의 Facebook
친구 사이트
공개SW 포털
OLIS
한국공개소프트웨어협회
AppCenter 지원본부
OLC
PSEG
개발자 블로그
블로터
개인 메뉴
메뉴 수정
양식함
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
특수 문서 목록
문서 정보