본문 바로가기

Development/Servers

윈도우에서 nodemon 사용시 팁

노드.js 작업시 서버의 js 파일을 수정했을 경우 노드 서버를 다시 실행시켜주는 유용한 모듈인 nodemon 이 기본 세팅으로는 윈도우에서 정상 작동하지 않는 경우가 있습니다.


nodemon 설치법


npm -g install nodemon

nodemon 사용법

nodemon -L app.js

webstrom 에 적용하면 아래와 같습니다.



-L  옵션은 nodemon 이 해당 디렉토리의 파일이 변경되는 것을 감지하는 옵션 중 하나로 문서에는 다음과 같이 설명하고 있습니다.


Help! My changes aren't being detected!

nodemon has three potential methods it uses to look for file changes. First, it polls using the find command to search for files modified within the last second. This method works on systems with a BSD based find (Mac, for example).

Next it tries using node's fs.watch. fs.watch will not always work however, and nodemon will try and detect if this is the case by writing a file to the tmp directory and seeing if fs.watch is triggered when it's removed. If nodemon finds that fs.watch was not triggered, it will then fall back to the third method (called legacy watch), which works by statting each file in your working directory looking for changes to the last modified time. This is the most cpu intensive method, but it may be the only option on some systems.

In certain cases, like when where you are working on a different drive than your tmp directory is on, fs.watch may give you a false positive. You can force nodemon to start using the most compatible legacy method by passing the -L switch, e.g.nodemon -L /my/odd/file.js.

위 옵션을 통해 윈도우 기반에서도 nodemon 을 정상적으로 사용하게 되었습니다.





'Development > Servers' 카테고리의 다른 글

ImageMagick 설치 관련  (0) 2012.12.22
zsh 사용해 봄  (0) 2012.11.30
Ubuntu 1204 LTS Server 셋업  (0) 2012.09.19
VSFTP 와 PHP 의 localtime 문제  (0) 2012.09.19
cafe24 클라우드 호스팅 셋업  (0) 2012.05.22