Nodemon手表选项损坏 [英] Nodemon watch option broken

查看:123
本文介绍了Nodemon手表选项损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gulp-nodemon

config目录只包含一个文件server.js。

  $。nodemon({
脚本:'config / server.js',
watch:['config / ** / *。 ();
.on('restart',function(){
setTimeout(function(){
$ .livereload.changed();
},1000);
});

输出:

  [gulp] [nodemon] v1.2.1 
[gulp] [nodemon]随时重启,输入`rs`
[gulp] [nodemon]正在看:config / ** /*.js
[gulp] [nodemon]启动`node config / server.js`
[gulp] [nodemon]观看34,325个文件 - 这可能会导致CPU使用率过高。减少使用 - 观察。

如果我包含一个忽略选项,它会修正。

 忽略:[
'node_modules / **',
'bower_components / **'
]



为什么nodemon会监视所有事件>从输出中看,它只能看到配置目录 [nodemon]正在看:config / ** / *。js

解决方案

这似乎是 nodemon 本身,因为我可以使用简单的 nodemon 命令重现它:

 > nodemon --watch app server.js 
[nodemon] v1.2.1
[nodemon]随时重启,输入`rs`
[nodemon]观看:app / ** / *
[nodemon]启动`node server.js`
[nodemon]观察72,981个文件 - 这可能会导致CPU使用率过高。减少使用--watch

默认行为 nodemon 是监视项目根目录中的所有目录
并忽略一些目录,如 node_modules bower_components .sass_cache 。这个默认的 ignore 实际上不起作用,但是在这个PR中修复了。应用此修复程序,我的输出与预期一致。

 > nodemon --watch app server.js 
[nodemon] v1.2.1
[nodemon]随时重启,输入`rs`
[nodemon]观看:app / ** / *
[nodemon]启动`node server.js`

我使用两种配置进行测试,即使发出警告,我的 nodemon 不会刷新不在指定的监视的目录中的文件更改,并且正如预期的那样工作,没有性能问题。这很可能是对我的假阳性警告。



但现在我建议你留在忽略直到它被合并到 nodemon 或者找到另一个解决方法。



这里有一些相关的问题:#46 #366 #32


I am using gulp-nodemon

config directory includes only one file, server.js.

$.nodemon({
  script: 'config/server.js',
  watch: ['config/**/*.js']
})
.on('restart', function () {
  setTimeout(function () {
    $.livereload.changed();
   }, 1000);
 });

Output:

[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".

If i include an ignore option it fixes.

ignore: [
  'node_modules/**',
  'bower_components/**'
]

Why does nodemon watch everything even when I tell it to watch only config directory?

Also it appears from the output it only watches the config directory [nodemon] watching: config/**/*.js

解决方案

This seems to be a bug with nodemon itself, because I was able to reproduce it using the simple nodemon command :

> 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"

The default behavior of nodemon is to watch all the directories in the root of your project, and to ignore some directories like node_modules, bower_components or .sass_cache. This default ignore don't work actually, but was fixed in this PR. Applying this fix, my output was just as expected.

> 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`

I tested using both configurations, and even with the warning, my nodemon was not refreshing on a file change that is not in the specified watched directory, and working just as expected with no performance issue. It's more likely a false-positive warning to me.

But for now I advice you to stay with your ignore rule until this is merged into nodemon or another workaround is found.

Here some related issues about that : #46, #366 and #32

这篇关于Nodemon手表选项损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆