javascript - Axosoft/nsfw文件监控器不会触发文件更改

标签 javascript node.js electron

以下问题仅在Windows上存在,在macOS上,以下代码按预期工作。
因此,我在Windows 10(v1909)上,在我的 Electron 程序中安装了nsfw,无法使其正常运行。我用以下命令安装了它:

npm install nsfw --save

> nsfw@2.0.0 install C:\Users\daniel\Desktop\my-foo-example\node_modules\nsfw
> node-gyp rebuild

C:\Users\daniel\Desktop\my-foo-example\node_modules\nsfw>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  NSFW.cpp
  Queue.cpp
  NativeInterface.cpp
  Controller.cpp
  Watcher.cpp
  win_delay_load_hook.cc
     Creating library C:\Users\daniel\Desktop\my-foo-example\node_modules\nsfw\build\Release\nsfw.lib a
  nd object C:\Users\daniel\Desktop\my-foo-example\node_modules\nsfw\build\Release\nsfw.exp
  nsfw.vcxproj -> C:\Users\daniel\Desktop\my-foo-example\node_modules\nsfw\build\Release\\nsfw.node
+ nsfw@2.0.0
我通过以下方式调用nsfw。我希望可以开始打印“开始观看”,但是什么也没发生。同样,给定目录中的任何文件更改都不会打印出来。该目录确实存在。我想念什么吗?

var watcher2;

app.whenReady().then(() => {
  createWindow();

  nsfw(
    "C:\\Users\\daniel\\Desktop\\foo",
    function (events) {
      console.log(events);
    },
    {
      debounceMS: 250,
      errorCallback(errors) {
        console.log(errors);
      },
    }
  )
    .then(function (watcher) {
      watcher2 = watcher;
      console.log("start"); <--- get's executed
      return watcher.start();
    })
    .then(function () {
      console.log("start watching"); <--- DOES NOT get triggered
      // we are now watching dir for events!
    });
});

最佳答案

我遇到了类似的问题,尤其是考虑到stop调用是 repo 示例中的一部分。但是,在您的情况下,您似乎没有.catch来显示实际的潜在错误。

关于javascript - Axosoft/nsfw文件监控器不会触发文件更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62779363/

相关文章:

JavaScript 命名空间全局变量与全局属性

angular - TypeError window.require不是一个函数-用Electron进行 Angular 测试

node.js - 在 Node 上安装 Electron 以使 Windows 挂起

node.js - 无法从 npm 安装 Electron

c# - Div 不会在更新面板中淡出

javascript - 如何只运行一次灯箱?

javascript - 使用 .slideUp() 后,响应式导航将无法打开

node.js - TFS Build 找不到 Grunt

node.js - 从Web服务器发送请求到本地服务器

javascript - NodeJS 流和请求模块