Typography

活版印字


  • Home
  • Archive
  • Categories
  • Tags
  •  

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo

nodemon 初探

Posted at 2016-11-03 nodemon 

安裝

npm install -g nodemon

用途

是一個可以監控檔案更變,自動將程序重啟的提升開發效率工具。

可以用在哪

預設可以執行 NodeJS 和 coffee script,其他程序(python, ruby)也支援,只是需要額外設定。

如何使用

node app.js

換成

nodemon app.js

nodemon ap.coffee

設定檔

若執行目錄下有 nodemon.json,它將會被載入,但是若你需要放在其他位置或其他名稱,你則需要指定。

nodemon --config my/custom/nodemon.json server.js

除此之外,你也未必一定要有設定檔,可以直接寫在 commend 參數中。

nodemon -w server.js libs api

設定在 commend 中的參數優先權較高,可以覆蓋設定檔中重複的設定值。

參數

  • exec:可執行非 node 或 coffee script 的程式
  • watch:指定監控更變的資料夾或檔案
  • ignore:排徐監控更變的資料夾或檔案
  • delay:延緩重啟時間

nodemon --delay 10 app.js

補充與 mocha 整合

nodemon --exec mocha test/**/lib.*.js

Share 

 Previous post: 我們辦公室沒有人 - 重點摘要(2) Next post: 我們辦公室沒有人 - 重點摘要(1) 

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo