Javascript 警告:检测到递归进程.nextTick
我有一个应用程序,我正开始使用它,我只是想运行它,但它崩溃了。它使用grunt运行节点服务器,它是Angular.js应用程序。当我运行运行服务器的grunt任务时,当我尝试从浏览器访问应用程序时,grunt或node发出警告:Javascript 警告:检测到递归进程.nextTick,javascript,node.js,recursion,gruntjs,Javascript,Node.js,Recursion,Gruntjs,我有一个应用程序,我正开始使用它,我只是想运行它,但它崩溃了。它使用grunt运行节点服务器,它是Angular.js应用程序。当我运行运行服务器的grunt任务时,当我尝试从浏览器访问应用程序时,grunt或node发出警告: (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive
(node) warning: Recursive process.nextTick detected. This will break in the next
version of node. Please use setImmediate for recursive deferral.
很多行,最后:
util.js:35
var str = String(f).replace(formatRegExp, function(x) {
^
RangeError: Maximum call stack size exceeded Use --force to continue.
Aborted due to warnings.
我试图在我的应用程序中搜索forprocess.nextTick
,但它位于node\u modules
目录中的很多地方,而不是src
目录中
是否有可能删除该警告以便我可以运行该应用程序?我应该为这个递归调用搜索什么代码
更新
我使用ack
发现这一行来自此文件的3个位置:
$REPO/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable- stream/node_modules/core-util-is/float.patch
$REPO/node_modules/grunt-browser-sync/node_modules/browser-sync/node_modules/connect/node_modu les/multiparty/node_modules/readable-stream/node_modules/core-util-is/float.patch
/usr/lib/node_modules/bower/node_modules/decompress-zip/node_modules/readable-stream/nod e_modules/core-util-is/float.patch
但它不是js文件。这可能是一个棘手的问题。如果你的命名习惯重复,咕噜声会呕吐 这将打破:
grunt.registerTask('foo', [ 'foo']);
这不会:
grunt.registerTask('foo', [ 'bar']);
查看此SO帖子:
npm重复数据消除
为我解决了它。基本上,它减少了包的重复:
搜索本地包树,并尝试通过将依赖项进一步向树上移动来简化总体结构,在树上多个依赖包可以更有效地共享这些依赖项
我在这里发布:
替代解决方案:检查手表是否有空文件参数
这是我的gruntfile
watch: {
all: {
options:{
livereload: true
},
files: ['src/scss/*.scss', 'src/foo.html',, 'src/bar.html'],
tasks: ['default']
}
}
在我的例子中,我可以使用上面的空参数按需重新创建原始海报的错误。在我的例子中,在抛出此错误之前,我得到了以下警告:
Running "watch" task
Waiting...
Warning: watch ENOSPC
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
此错误表示它尝试监视的资源数高于此用户的限制。这就是为什么以root用户身份运行(没有这些限制)可以正常工作的原因。但这不是一个解决方案
了解Linux中用户的限制:
sysctl --all | grep watches
尝试增加当前用户的手表数量:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
这应该可以解决问题。将您提供给replace()的内联函数发布到Related:另外:可能编写它的人没有收到所有这些错误。也许您应该在节点
v0.8.0
上运行它?找到了原因,这是因为资源限制(我认为是因为堆栈大小)。我的帐户有限制,我甚至不知道linux上有类似的限制。当我从根目录运行应用程序时,它工作正常。@AlexanderBurakevych我在linux上用sudo
运行应用程序,它工作正常。@jcubic核心问题(至少在我的情况下)是用户手表的数量有限:fs.inotify.max\u user\u手表。一旦设置为更高的数字,它就工作得很好。我猜sudo用户没有这个限制。