Node.js electron(atom shell)Module.require的源代码在哪里?

Node.js electron(atom shell)Module.require的源代码在哪里?,node.js,electron,Node.js,Electron,我使用的是一个自定义require函数,它模仿并运行良好 然而,在电子中,我得到 SecurityError: An attempt was made to break through the security policy of the user agent. 在自定义所需代码内调用窗口时。addEventListener 如果我能阅读electron'require'函数的源代码,我可能会理解我的版本失败的原因。你要找的应该在GitHub上 或 或 根据您的更新,您正在寻找的代码(关于

我使用的是一个自定义require函数,它模仿并运行良好

然而,在电子中,我得到

SecurityError: An attempt was made to break through the security policy of the user agent.
在自定义所需代码内调用
窗口时。addEventListener


如果我能阅读electron'require'函数的源代码,我可能会理解我的版本失败的原因。

你要找的应该在GitHub上

或 或

根据您的更新,您正在寻找的代码(关于共享全局上下文)实际上如下所示:


由于Electron没有包含最新版本的Node.js,我认为值得一提。

使用
toString
检查后,源代码与nodejs相同,只是在
模块时编译。_contextload
为真。这一部分似乎被优化了


我的代码现在通过使用编译正确工作,因此表现为来自同一来源(chromium中的XSS预防)。这与electron中的
require
功能相同。

事实上,没有。atom/electron sources.Np中没有模块。谢谢你的解决方案!我仍然不知道为什么addEventListener触发了看起来像沙盒上下文的内容。这是错误的真正来源吗,或者你能说出它是什么吗?Nm。。。查找XSS。我现在了解了意外的上下文是如何触发错误的。我在一些函数上使用toString()来发现差异。唯一的更改与模块有关。\u contextload strip out。