mustache-js 视图不会使用 nodemon 自动刷新
mustache-js views don't auto-refresh with nodemon
我已经使用 nodemon 一段时间了,这样我就不用在编辑文件时重新启动服务器了。
现在我切换到使用 mustache.js 模板,神奇的始终最新停止工作 - 我现在需要手动重新启动服务器以使我的更改生效。
这是一个错误吗?配置错误?
澄清一下:每当我编辑 .mustache 文件时,我都需要手动重启服务器才能看到我的更改。
更改 html 小胡子模板 不会 导致服务器使用 nodemon 重新启动。
但就我而言,我可以简单地编辑一个html小胡子模板文件,保存它,然后刷新页面(无需重新启动服务器),我可以看到所做的更改。
或许,请尝试检查您的路由并确保您呈现正确的模板文件。
从 我将启动脚本更改为
"start": "nodemon -e js,mustache ./server.js",
为了指定 Nodemon 应该在哪些文件上 auto-refresh,您可以设置 package.json 以 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 和 .mustache 文件:
> 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
我已经使用 nodemon 一段时间了,这样我就不用在编辑文件时重新启动服务器了。
现在我切换到使用 mustache.js 模板,神奇的始终最新停止工作 - 我现在需要手动重新启动服务器以使我的更改生效。
这是一个错误吗?配置错误?
澄清一下:每当我编辑 .mustache 文件时,我都需要手动重启服务器才能看到我的更改。
更改 html 小胡子模板 不会 导致服务器使用 nodemon 重新启动。
但就我而言,我可以简单地编辑一个html小胡子模板文件,保存它,然后刷新页面(无需重新启动服务器),我可以看到所做的更改。
或许,请尝试检查您的路由并确保您呈现正确的模板文件。
从
"start": "nodemon -e js,mustache ./server.js",
为了指定 Nodemon 应该在哪些文件上 auto-refresh,您可以设置 package.json 以 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 和 .mustache 文件:
> 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