#region #endregion c#

한블록에서 코드를 여러 블록으로 관리할때 사용

#region 작업1
.
.
code
.
.
#endregion 


한블록으로 지정된 경우 확대 축소를 할수있어 작업에 용이하다.



node.js module node.js

1. exports
모듈 안에 선언한 항목을 다른 모듈이 사용하려면 exports 객체를 사용해야한다.
ex)
//test.js
exports.test_log = 'test_log'
//app.js
const test = require('./test.js');
console.log('test log: ${test.test_log}');

2. module.exports
module.exports 객체에 하나의 값 만을 할당한다.

ex)
//num.js
module.exports = function (num) {
return {
num() {return num;},
sum() {return num+num;}
};
//app.js
const num = require('./num.js');
const test = num(5);
console.log('test log: ${test.num()}');
console.log('test log: ${test.sum()}');

3. require
코어 모듈과 npm을 통해 설치한 외부 패키지는 패스를 명시하지 않아도 된다.



ubuntu nodejs설치 및 기본세팅 node.js

1. nodesource의 apt 저장소 추가
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

2. nodejs 설치
apt-get install nodejs

3. packge.json 파일로 프로젝트 정보와 dependency 기록
npm init -y

3. npm으로 패키지 설치
npm install 패키지이름
*) npm install 만 실행할경우 package.json 에 명시된 의존 패키지를 한번에 설치할 수 있다.




특정포트를 사용하는 프로그램 종료

-특정 포트에 접속중인 ip리스트 확인
  netstat -nap |grep 포트번호 
ex) netstat -nap |grep 3000

-특정 포트에서 사용하는 프로그램 확인
lsof -i tcp:포트번호
ex) lsof -i tcp:3000

-특정포트 사용 프로그램 종료
fuser -k -n tcp 포트번호
ex) fuser -k -n tcp 3000

node.js 기초 node.js

node.js - 이벤트 기반의 비동기 방식.



1 2 3 4 5 6 7 8 9 10 다음