Node.js 는 소스 변경시 재기동해줘야 하는데, nodemon 을 사용하면 자동 재기동이 가능함.
주로 개발에서 사용하고, 운영에서는 forever 를 주로 사용함.
개발에만 집중할 수 있도록 도와주는 패키지.
npm i nodemon -g ==> global 로 설치
npm i -d nodemon ==> package.json
Either through cloning with git or by using npm (the recommended way):
npm install -g nodemon
And nodemon will be installed globally to your system path.
You can also install nodemon as a development dependency:
npm install --save-dev nodemon
With a local installation, nodemon will not be available in your system path. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as npm start) or using npx nodemon.
--save-dev 로 하면 개발 dependencies 에만 들어간다.
실행 :
=> 로컬로 설치하면 nodemon 실행시 명령어를 찾지 못한다.
이때는 npx 로 실행해야 한다. 글로벌로 설치하면 nodemon 으로 실행할 수 있다.
~/Projects/NodeJS/express-first$ npx nodemon app.js
더 나은 방법으로...package.json 파일에 아래처럼 start 부분을 추가하는 것이다.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "npx nodemon app.js" <======추가된 부분
},
그리고 실행방법은...
npm start
'IT > JavaScript와 Framework' 카테고리의 다른 글
morgan 설치 (0) | 2021.06.17 |
---|---|
미들웨어 사용 예제 (0) | 2021.06.17 |
express 프레임웍 샘플 2 - 클라이언트 요청받아 응답받기 (0) | 2021.06.16 |
express 프레임 웍 사용예제 (0) | 2021.06.16 |
express 프로젝트 만들기 (0) | 2021.06.16 |
댓글