nodejs 설치후 $ node app.js 등과 같이 app을 실행시킬때 다음과 같은 에러가 발생하는 경우가 있다.

  •  /usr/bin/env: node: No such file or directory

원인은 node 명령이 등록이 되지않아서 인데, 실제로 nodejs 라는 명령으로 실행하면 실행이 된다.


이때는 다음과 같이 nodejs의 심볼릭 링크를 만들어 주면 된다.

  • $ ln -s /usr/bin/nodejs /usr/local/bin/node

이후 $ node app.js 명령이 실행이 된다.


참고: https://github.com/nodejs/node-v0.x-archive/issues/3911

'Node.js' 카테고리의 다른 글

[Node.js][Winston] Log File Managment  (0) 2017.02.03
[Node.js][Winston] Custom Log Format  (0) 2017.02.03
[Node.js] NVM을 통한 nodejs 설치  (0) 2016.12.21
[BOWER] Proxy 설정  (0) 2016.12.16
[NPM] Proxy 설정  (1) 2016.12.16
Posted by leechwin
,

Javascript 내의 function 들의 성능 체크를 위해 시간을 측정하는 여러 방법에 대해 알아본다.


Performance.now()

var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");


Console.time() - Non-standard

console.time('performance');
doSomething();
console.timeEnd('performance');

참조: http://stackoverflow.com/questions/313893/how-to-measure-time-taken-by-a-function-to-execute



Posted by leechwin
,

Git Push 시에 등록된 여러 Reviewer를 등록하는 방법에 대해 알아보자.


Git Config 파일을 수정하는 방법

  • Git Clone 이후에 {repo}/.git/config 파일에 receivepack 명령어를 넣는 방법
  • 방법
    • Git Clone
    • {repo}/.git/config 파일에 다음과 같이 수정
      • receivepack 명령어에 리뷰어들을 모두 넣어 등록
        • [remote "origin"]
          url = blabla...
          fetch = +refs/heads/*:refs/remotes/origin/*
          receivepack = git receive-pack --reviewer={email} --reviewer={email} --reviewer={email} 
    • 이후 git push 명령시에 자동으로 Gerrit reviewer 들이 등록된다.
  • 단점
    • 각 Git Repository 마다 config 설정을 해줘야 한다.
    • Git Repository를 통째로 삭제하고, Git Clone을 다시 받으면, config 파일도 삭제되기 때문에 위의 작업을 다시해야한다.


Bash Command로 등록하는 방법

  • Bash command로 "git-push" 라는 wrapper command를 작성하여 global 하게 reviewer를 등록하는 방법
  • 방법
    • bashrc 파일을 다음과 같이 수정
      • $ vi ~/.bashrc
      • function git-push() {
            git push --receive-pack='git receive-pack --reviewer {email} --reviewer {email}' origin HEAD:refs/for/$1
        }
    • 수정된 .bashrc 파일을 실행
      • $ source ~/.bashrc
    • 이후 어디에서나 다음과 같은 command를 사용 가능
      • $ git-push {branch}
      • $ git-push develop
      • $ git-push master
    • 위의 명령 실행시 자동으로 Gerrit reviewer 들이 등록된다.
  • 장점
    • 각 Git Repository 마다 config 설정이 필요없이 어느 Git Repository에서나 사용 가능
  • 단점
    • push 와 동시에 리뷰어가 자동 등록 되 커밋 별 선택적 리뷰어 등록이 불가능.
    • 경우에 따라 등록된 리뷰어를 다시 지울 필요가 있거나 version up 등 모든 리뷰어 등록이 필요 없는 경우 불편할 수 있다.


Posted by leechwin
,

[Git] 기본설정

Git 2016. 12. 21. 14:59

Git 사용시 기본 설정방법에 대해 알아본다.


Git 설정확인

  • $ git config --list


기본사용자설정

  • $ git config --global user.name "ChangHyun Lee"
  • $ git config --global user.email leechwin1@gmail.com


Commit Template 설정

  • $ git config --global commit.template {Template 파일 경로}
  • $ git config --global commit.template /home/leechwin/git/commit.template


Commit Template 해제

  • config --global --unset commit.template


색상 설정

  • $ git config --global color.ui true


CRLF 설정(커밋시 CRLF를 LF로 변환)

  • Linux
    • $ git config --global core.autocrlf input
  • Windows
    • $ git config --global core.autocrlf true

SSH Config 설정
  • ~/.ssh/config 파일 설정 예제
    • Host tizen
    • User leechwin
    • Port 29418
    • Hostname review.tizen.org
    • IdentityFile ~/.ssh/id_rsa
  • Proxy 환경일 경우 Proxy 설정 추가
    • ProxyCommand nc -x111.111.111.111:18080 -Xconnect review.tizen.org 29418

Change ID 자동설정 예제
  • $ cd gitDir
  • $ scp -p -P 29418 leechwin@review.tizen.org:hooks/commit-msg .git/hooks/
  • SSH Config 설정이 되어있다면
    • $ scp -p -P 29418 tizen:hooks/commit-msg .git/hooks/


설정된 속성은 다음 파일에 저장된다.

  • /etc/gitconfig : 시스템 전역 ( git config --system )
  • ~/.gitconfig : 특정 사용자 ( git config --global )
  • .git/config : 특정 Git


Posted by leechwin
,

NVM(Node Version Manager)를 통한 nodejs 설치에 대해 알아보자.


NVM을 통하여 기존 설치된 node.js 버전을 변경하는 동작도 가능하다.


다음 명령을 통해 NVM을 설치한다.

  • $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

설치된 NVM 버전은 다음 명령을 통해 확인 가능하다.

  • $ nvm --version
  • 0.32.1

NVM 설치가 잘 안되면 아래 명령으로 개발에 필요한 기본 패키지를 설치한다.

  • $ apt-get install build-essential libssl-dev


NVM 설치가 끝나면 다음과 같이 원하는 버전의 nodejs를 설치한다.

  • $ nvm install v12.18.2

$ nvm install v12.18.2

Downloading and installing node v12.18.2...

Downloading https://nodejs.org/dist/v12.18.2/node-v12.18.2-linux-x64.tar.xz...

######################################################################## 100.0%

Computing checksum with sha256sum

Checksums matched!

Now using node v12.18.2 (npm v6.14.5)


NVM을 통해 nodejs가 설치되면서 npm도 같이 설치가 된다.

  • $ npm -v
  • 3.10.8

현재 설치된 nodejs 버전은 다음 명령으로 확인가능하다.

  • $ nvm ls

$ nvm ls

       v10.17.0

->     v12.18.2

default -> v10.17.0

node -> stable (-> v12.18.2) (default)

stable -> 12.18 (-> v12.18.2) (default)

iojs -> N/A (default)

lts/* -> lts/erbium (-> v12.18.2)

lts/argon -> v4.9.1 (-> N/A)

lts/boron -> v6.17.1 (-> N/A)

lts/carbon -> v8.17.0 (-> N/A)

lts/dubnium -> v10.21.0 (-> N/A)

lts/erbium -> v12.18.2

 


현재 사용중인 nodejs 버전은 다음 명령으로 확인가능하다.

  • $ nvm current
  • v12.18.2
기본 nodejs 버전을 설정하려면 다음 명령으로 변경가능하다.
  • $ nvm alias default v12.18.2
  • default -> v12.18.2


Posted by leechwin
,

Bootstrap 의 Input 태그 사용시 아래와 같이 입력한 text를 지우는 기능을 넣는 방법에 대한 코드


HTML

});

CSS

::-ms-clear {
  display: none;
}
.form-control-clear {
  z-index: 10;
  pointer-events: auto;
  cursor: pointer;
}

JavaScript

$('.form-control').on('input change', function() {
  var $this = $(this);
  var visible = Boolean($this.val());
  $('.form-control-clear').toggleClass('hidden', !visible);
}).trigger('propertychange');

$('.form-control-clear').on('click', function() {
  $('.form-control').val('').trigger('change').focus();
  $(this).toggleClass('hidden', true);
});


Reference: https://codepen.io/frosdqy/pen/grbxGW



Posted by leechwin
,

fontawesom 라이브러리는 HTML 파일내에서 알려진 특정 아이콘을 사용하기 쉽게 제공한다.

라이브러리를 다운로드 받아 사용하지 않고 CDN을 사용하려면 다음 주소를 사용하면 된다.


아래의 아이콘리스트중 사용하고 싶은 아이콘이 있다면 <i> 태그안에 class 속성으로 아이콘 이름을 넣어주면된다.

예제

  • <i class="fa fa-bus" aria-hidden="true"></i>

fontawesome의 <i> 태그는 Bootstrap 을 이용하고 있다면 <span> 태그를 대체 가능하다.

  • <span class=glyphicon glyphicon-remove"></span>


'Web' 카테고리의 다른 글

[Javascript] 함수 Performance 체크  (0) 2016.12.25
[Bootstrap] Input 태그의 Clear 버튼  (0) 2016.12.16
[Chrome] 웹페이지의 글자가 흐릿하게 나오는 경우  (0) 2016.01.08
[Chrome] Cache 삭제  (0) 2015.12.31
DOMNodeRemoved event  (0) 2015.12.30
Posted by leechwin
,

[BOWER] Proxy 설정

Node.js 2016. 12. 16. 11:01

bower install 실행시에 Proxy 환경일 경우 제대로 설치가 안되는 경우가 있다.


이때에는 bower.json 파일이나 .bowerrc 파일에 Proxy 설정이 필요하다.


예제

  • {
      "proxy": "http://yourProxy:yourPort",
      "https-proxy": "http://yourProxy:yourPort",
      "strict-ssl": false,
      "directory": "bower_components",
      "registry":"http://bower.herokuapp.com"
    }
만약 bower install 명력이 동작안하는 경우 bower.json 파일을 .bowerrc 로 변경해서 bower install 을 수행하여 본다.

bower.json 은 최신 bower버전에서 도입되어 구버전의 bower일 경우 인식안되는 경우가 있다.


Posted by leechwin
,

[NPM] Proxy 설정

Node.js 2016. 12. 16. 10:59

npm install 실행시에 Proxy 환경일 경우 제대로 설치가 안되는 경우가 있다.


이때에는 다음과 같이 npm config 명령을 통해 Proxy 설정이 필요하다.


예제

  • npm config set proxy http://111.111.111.111:8081
  • npm config set https-proxy https://111.111.111.111:8081
  • npm config set strict-ssl false
  • npm config set registry http://registry.npmjs.org/

npm 설정값은 다음 명령으로 확인가능하다.

  • npm config list
설정된 값은 ~/.npmrc 파일에 저장되어 있다.


Posted by leechwin
,