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