커피닉스, 시스템 엔지니어의 쉼터
  FreeBSD에서 node.js용 zmq 설치 작성일 : 2014/12/23 18:28
 
  • 글쓴이 : 좋은진호 ( http://coffeenix.net/ )
  • 조회수 : 9439
     
    제  목 : FreeBSD에서 node.js용 zmq 설치
    작성일 : 2014.11.18(화)
    작성자 : 좋은진호(truefeel, http://coffeenix.net/ )


    1. ZeroMQ 라이브러리 설치

     
    # pkg install libzmq3 또는
    # pkg install libzmq4
     



    2. node.js zmq 설치

    1) local 디렉토리에 install (현재디렉토리/node_modules/zmq/)

     
    # npm install zmq
     


    2) global 디렉토리에 install하려면 (/usr/local/lib/node_modules/zmq/)

     
    # npm install -g zmq
     


    3) 다음과 같은 에러가 나온다면

     
    \
    > zmq@2.8.0 install /home/cnx/node_modules/zmq
    > node-gyp rebuild

    gyp ERR! configure error
    gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
    gyp ERR! stack     at failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14)
    ... 생략 ...
    gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /home/cnx/node_modules/zmq
    ... 생략 ...
     


    python을 찾지 못해서 발생한 문제이다. python이 python2 이름으로 설치되는 경우가 있는데, 심볼릭 링크를 걸어준다.

     
    # cd /usr/local/bin
    # ln -s python2 python
    # ls -la python
    lrwxr-xr-x  1 root  wheel     7 Nov 17 16:23 python -> python2
     



    3. require()에서 모듈 경로 지정

     
    var zmq = require('zmq');
     


    require() 로 모듈지정할 때, 기본적으로 다음 같은 경로에서 찾는다.

     
    $HOME/.node_modules
    $HOME/.node_libraries
    $HOME/node_modules
    $PREFIX/lib/node (예. /usr/local/lib/node)
     


    이외 디렉토리에 모듈이 존재하면 3가지 방법 중에 선택한다.

    1) require() 에 경로를 지정하거나
    2) export NODE_PATH=/usr/local/lib/node_modules (csh은 setenv NODE_PATH /usr/local/lib/node_modules) 환경 변수를 지정하거나
    3) npm install -g 로 글로벌하게 설치했다면, /usr/local/lib/node_modules를 심볼릭 링크를 건다.
     
    # cd /usr/local/lib
    # ln -s node_modules node
     


    개인적으로는 글로벌하게 설치해서, 3번 방법으로 사용중.


    4. 참고 자료

    * ZeroMQ
      http://kr.zeromq.org/
      http://zeromq.org/

    * JustinTulloss/zeromq.node (테스트용 소스 있음)
      https://github.com/JustinTulloss/zeromq.node


    커피닉스, 시스템 엔지니어의 쉼터 / URL : http://coffeenix.net/board_view.php?bd_code=1764