2016-12-26 28 views
3

我一直在使用nodemon一段時間來節省我編輯文件時重新啓動服務器的麻煩。mustache-js視圖不會使用nodemon自動刷新

現在我切換到使用mustache.js模板,並且始終保持最新的魔術停止工作 - 現在我需要手動重新啓動服務器以使我的更改生效。

這是一個錯誤?配置錯誤?

澄清:無論何時編輯.mustache文件,我都需要手動重新啓動服務器以查看我的更改。

回答

1

this answer我改變了我的啓動腳本

"start": "nodemon -e js,mustache ./server.js",

0

更改html小鬍子模板wont導致服務器使用nodemon重新啓動。

但在我的情況,我可以簡單地編輯一個html鬍子模板文件,保存它,刷新頁(無需重新啓動服務器),我可以看到所做的更改。

也許,試着檢查你的路由,並確保你正在渲染正確的模板文件。

+0

我正在渲染正確的文件...但在我的設置中,我必須重新啓動節點服務器以使鬍鬚文件中的更改生效。 – ripper234

0

爲了指定哪些文件應該Nodemon自動刷新,您可以設置的package.json與一個nodemon開始Nodemon。 json配置文件,其中包括要監視的文件擴展名。例如:

添加到的package.json文件:

"scripts": { 
    "dev": "nodemon --config nodemon.json" 
    }, 

創建nodemon.json文件:

{ 
    "verbose": true, 
    "execMap": { 
     "js": "node --harmony" 
    }, 
    "script": "server.js", 
    "ext": "js mustache" 
} 

現在運行的時候,你應該看到nodemon是看的.js and .mustache files:

> npm run dev 

[nodemon] 1.11.0 
[nodemon] reading config nodemon.json 
[nodemon] watching extensions: js,mustache 
[nodemon] starting `node --harmony server.js` 
[nodemon] child pid: 7740 
[nodemon] watching 5 files