我想用Chokidar看我的应用程序中的文件。问题是,每当您尝试实例化chokidar.watch时,电子都会抛出一个错误。我想知道这是否是这两者之间的一个已知的兼容性问题,以及是否有一个内置的解决方案来解决这个问题。到目前为止,谷歌对于在电子应用程序中观看文件没有任何好处。此错误仅在使用chokidar对象时发生。要求它不会引起问题。
呈现程序过程中的代码如下所示。注释掉var观察者代码将完全消除控制台错误。代码直接来自他们的文档。
var chokidar = remote.require('chokidar');
chokidar.watch('.', {ignored: /[\/\\]\./}).on('all', function(event, path) {
console.log(event, path);
});控制台错误:
Uncaught Error: criterion.test is not a function
TypeError: criterion.test is not a function
at testCriteria (/Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/node_modules/anymatch/index.js:29:26)
at Array.some (native)
at anymatch (/Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/node_modules/anymatch/index.js:59:48)
at EventEmitter.FSWatcher._isIgnored (/Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/index.js:221:15)
at EventEmitter.NodeFsHandler._addToNodeFs (/Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/lib/nodefs-handler.js:429:12)
at EventEmitter.<anonymous> (/Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/index.js:410:12)
at /Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/node_modules/async-each/index.js:16:7
at Array.forEach (native)
at each (/Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/node_modules/async-each/index.js:15:11)
at EventEmitter.FSWatcher.add (/Users/guest/Desktop/prototype/yeti-launch/node_modules/chokidar/index.js:409:5)任何关于如何在我的项目中增加观看的建议都是非常感谢的。Atom编辑器检测使用文件资源管理器添加文件和文件夹的时间,并在侧栏中适当地显示最新的文件夹信息。如果原子能做到,我的应用程序也能做到!
发布于 2015-11-09 09:31:24
这可能破坏了电子远程对象的所有规则--但您可以尝试访问远程版本的chokidar
var chokidar = global\['require'\]('remote').require('chokidar');https://stackoverflow.com/questions/30787590
复制相似问题