node.js - Electron (原子壳)Module.require的源代码在哪里?

标签 node.js electron

我正在使用模仿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/

相关文章:

javascript - express , Passport : can't set headers after they are sent

javascript - 如何在javascript中获取数组对象内的对象?

javascript - 在 NodeJS 上添加异步函数时出现错误

node.js - Electron import x509 cert to local keychain (macOS) - 授权被拒绝,因为无法进行用户交互

javascript - youtube-dl nodejs 有问题 错误 : spawn EACCES

node.js - 获取 Azure Blob 存储中可用元素数量的总文件大小

javascript - 一旦我设置了nodeIntegration :false -> “Uncaught ReferenceError: require is not defined at Object.url (external ” url“:1) ” #electron-#react-#typescript

node.js - Windows 上的 Electron Packager 什么都不做

vuejs2 - 在electronic-vue项目中使用boots-vue组件会导致数据属性更改错误

node.js - 在打包 Electron 桌面应用程序时包含 node_modules?