我正在使用 gulp-nodemon
config 目录只包含一个文件 server.js.
config directory includes only one file, server.js.
$.nodemon({
script: 'config/server.js',
watch: ['config/**/*.js']
})
.on('restart', function () {
setTimeout(function () {
$.livereload.changed();
}, 1000);
});
输出:
[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/**'
]
即使我告诉它只看配置目录,为什么 nodemon 还要看一切?
Why does nodemon watch everything even when I tell it to watch only config directory?
从输出中也可以看出,它只监视配置目录 [nodemon] 监视:config/**/*.js
Also it appears from the output it only watches the config directory [nodemon] watching: config/**/*.js
这似乎是 nodemon 的错误 本身,因为我能够使用简单的 nodemon 命令重现它:
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"
nodemon 的默认行为是监视项目根目录下的所有目录,并忽略一些目录,如 node_modules、bower_components 或 .sass_cache.这个默认的 ignore 实际上不起作用,但已在 此 PR 中修复.应用此修复程序,我的输出与预期一样.
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`
我使用这两种配置进行了测试,即使出现警告,我的 nodemon 也没有刷新不在指定 watched 目录中的文件更改,并且正常工作正如预期的那样,没有性能问题.这更可能是对我的误报警告.
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.
但现在我建议您坚持使用 ignore 规则,直到将其合并到 nodemon 或找到其他解决方法.
But for now I advice you to stay with your ignore rule until this is merged into nodemon or another workaround is found.
这里有一些相关的问题:#46, #366 和 #32
Here some related issues about that : #46, #366 and #32
这篇关于Nodemon监视选项损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
由于 MIME 类型而未加载样式表Stylesheet not loaded because of MIME-type(由于 MIME 类型而未加载样式表)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)