1. nodemon
nodemon이 무엇일까?
npm에서 nodemon에 대한 정의는 다음과 같다.
nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
간단하게 말하면 우리가 node.js로 만든 애플리케이션의 변화(코드 수정)가 있을 때 자동으로 애플리케이션을 재실행시켜주는 도구이다.
1 - 1) 설치
npm install -g nodemon //전역적 설치
npm install --save-dev nodemon //특정 디렉토리 내에서만 사용
1 - 2) 사용법
node.js 애플리케이션을 서버로 동작시킬 때 node app.js 와 같이 사용하는데 이때 node 부분을 nodemon으로만 바꿔주면
nodemon을 사용할 수 있다.
1 - 3) cli options
Configuration |
--config <file> .......... alternate nodemon.json config file to use |
--exitcrash .............. exit on crash, allows nodemon to work with other watchers |
-i, --ignore ............. ignore specific files or directories |
--no-colors .............. disable color output |
--signal <signal> ........ use specified kill signal instead of default (ex. SIGTERM) |
-w, --watch path ......... watch directory "dir" or files. use once for each |
directory or file to watch |
--no-update-notifier ..... opt-out of update version check |
Execution |
-C, --on-change-only ..... execute script on change only, not startup |
--cwd <dir> .............. change into <dir> before running the script |
-e, --ext ................ extensions to look for, ie. "js,pug,hbs" |
-I, --no-stdin ........... nodemon passes stdin directly to child process |
--spawn .................. force nodemon to use spawn (over fork) [node only] |
-x, --exec app ........... execute script with "app", ie. -x "python -v" |
-- <your args> ........... to tell nodemon stop slurping arguments |
Watching |
-d, --delay n ............ debounce restart for "n" seconds |
-L, --legacy-watch ....... use polling to watch for changes (typically needed |
when watching over a network/Docker) |
-P, --polling-interval ... combined with -L, milliseconds to poll for (default 100) |
Information |
--dump ................... print full debug configuration |
-h, --help ............... default help |
--help <topic> ........... help on a specific feature. Try "--help topics" |
-q, --quiet .............. minimise nodemon messages to start/stop only |
-v, --version ............ current nodemon version |
-V, --verbose ............ show detail on what is causing restarts |
2. Debugging for node.js
nodejs.org/ko/docs/guides/debugging-getting-started/
디버깅 - 시작하기 | Node.js
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
nodejs.org
자세한 내용은 위 공식 문서에서 찾아볼 수 있다.
node.js 에서 간단한 경우에는 console.log 를 통해 디버깅을 할 수 있지만 좀 더 원본 객체를 뜯어보거나 해야 할 경우
단순히 콘솔만 찍어서는 디버깅이 어렵다.
이 때 --inspect 옵션을 주면 크롬 개발자 도구에서 node.js를 디버깅할 수 있다!
또한 해당 --inspect 옵션은 위에서 설명한 nodemon에도 줄 수 있다!
'CodeStates' 카테고리의 다른 글
Sequelize ORM (0) | 2021.03.07 |
---|---|
MVC Design Pattern (0) | 2021.03.03 |
IM 32일차 (Postman 사용법) (0) | 2021.02.12 |
IM 31일차 (MIME type 과 HTTP headers 의 Content-Type) (0) | 2021.02.11 |
IM 26일차 (CORS) (0) | 2021.02.06 |