node.js - Electron : Net from Nodejs doesn't trigger events on Windows build

标签 node.js electron

我使用来自 Nodejs 的模块 Net 创建了一个端口扫描器功能,但该功能在我的 Windows 版本上不起作用。
我没有错误,我只是没有来自事件函数的任何触发器。
它在我的 Webstorm(在 MacOS 上)中完美运行。
有人知道根本原因吗?
PS:我启用了 nodeIntegration。
感谢您的回答!

最佳答案

As per the doc said :-

On Windows, the local domain is implemented using a named pipe. The path must refer to an entry in \?\pipe\ or \.\pipe. Any characters are permitted, but the latter may do some processing of pipe names, such as resolving .. sequences



JavaScript 字符串转义需要使用额外的反斜杠转义指定路径,例如:
net.createServer().listen(
  path.join('\\\\?\\pipe', process.cwd(), 'myctl'));

尝试一下,希望它会有所帮助!

关于node.js - Electron : Net from Nodejs doesn't trigger events on Windows build,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59372780/

相关文章:

Javascript 变量永远不会被赋值

electron - 从electronjs项目创建debian文件时显示错误

python - 使用 angular-electron 打包可执行二进制文件

reactjs - Electron 无框浏览器窗口无法完全删除Mac上的整个框架/标题栏

javascript - 从 Electron 主线程运行批处理文件

c++ - 在mbed微 Controller (c++)上加密AES128-CBC并在nodejs中解密AES128-CBC

javascript - 如何使 Node 和 React 应用程序共享类

node.js - 我将如何为用户实现加密/解密,同时还能够解密服务器端的所有内容

javascript - 使用 Node : "$.ajax is not a function" 执行 js 代码时出错

menu - 非导出接口(interface)的类型断言