我正在使用模仿nodejs require的自定义require 函数,并且可以正常工作。
但是,在 electronic 中,我得到了
SecurityError: An attempt was made to break through the security policy of the user agent.
在自定义所需代码中调用
window.addEventListener
时。如果我可以阅读 Electron 的“require”功能的源代码,那么我可能可以理解为什么我的版本失败了。
最佳答案
您要查找的内容应该在GitHub上。
https://github.com/atom/atom
或者...
https://github.com/atom/electron
或者...
https://github.com/atom/node
根据您的更新,您正在寻找的代码(关于共享全局上下文)实际上在这里:https://github.com/atom/node/blob/atom-iojs/lib/module.js#L399
因为Electron不包含最新版本的Node.js,所以我认为值得一提。
关于node.js - Electron (原子壳)Module.require的源代码在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30578617/