1.安裝nodemon:
npm install -g nodemon //全局安裝
npm install nodemon --save //局部安裝
2.在項目根目錄下創建 nodemon.json 文件
{ "restartable": "rs", "ignore": [ ".git", ".svn", "node_modules/**/node_modules" ], "verbose": true, "execMap": { "js": "node --harmony" }, "watch": [ ], "env": { "NODE_ENV": "development" }, "ext": "js json" }
配置項代表的含義:
restartable:設置重啟模式
ignore:設置忽略文件
verbose:設置日志輸出模式,true 詳細模式
execMap:設置運行服務的后綴名與對應的命令
{
“js”: “node –harmony”
}
表示使用 nodemon 代替 node
watch:監聽哪些文件的變化,當變化的時候自動重啟
ext:監控指定的后綴文件名
3.配置已經完成了,現在就差在cmd里輸入:
nodemon app.js
就可以運行了