egu*_*eys 5 javascript node.js nodemon gulp
我正在使用gulp-nodemon
config目录只包含一个文件server.js.
$.nodemon({
script: 'config/server.js',
watch: ['config/**/*.js']
})
.on('restart', function () {
setTimeout(function () {
$.livereload.changed();
}, 1000);
});
Run Code Online (Sandbox Code Playgroud)
输出:
[gulp] [nodemon] v1.2.1
[gulp] [nodemon] to restart at any time, enter `rs`
[gulp] [nodemon] watching: config/**/*.js
[gulp] [nodemon] starting `node config/server.js`
[gulp] [nodemon] watching 34,325 files - this might cause high cpu usage. To reduce use "--watch".
Run Code Online (Sandbox Code Playgroud)
如果我包含一个忽略选项它修复.
ignore: [
'node_modules/**',
'bower_components/**'
]
Run Code Online (Sandbox Code Playgroud)
为什么即使我告诉它只观看配置目录,nodemon也会监视所有内容?
它也从输出中看出它只监视config目录 [nodemon] watching: config/**/*.js
Bal*_*zar 18
这似乎是nodemon本身的一个错误,因为我能够使用简单的nodemon命令重现它:
> nodemon --watch app server.js
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/**/*
[nodemon] starting `node server.js`
[nodemon] watching 72,981 files - this might cause high cpu usage. To reduce use "--watch"
Run Code Online (Sandbox Code Playgroud)
默认行为nodemon是监视项目根目录中的所有目录,并忽略某些目录,如node_modules,bower_components或.sass_cache.此默认值ignore实际上不起作用,但已在此PR中修复.应用此修复程序,我的输出就像预期的那样.
> nodemon --watch app server.js
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/**/*
[nodemon] starting `node server.js`
Run Code Online (Sandbox Code Playgroud)
我使用这两种配置测试,即使有警告,我nodemon也没有刷新不在指定watched目录中的文件更改,并且正常工作而没有性能问题.这对我来说更像是一个误报警告.
但是现在我建议你坚持你的ignore规则,直到它被合并到nodemon或找到另一个解决方法.
| 归档时间: |
|
| 查看次数: |
8340 次 |
| 最近记录: |