【问题标题】:Node.js source code of require() functionrequire() 函数的 Node.js 源码
【发布时间】:2019-05-18 11:41:46
【问题描述】:

根据文档 (https://nodejs.org/api/globals.html),require() 函数是全局对象/函数之一。但是我很难在 Github 上找到它的源代码。它们是用 JS 还是 C++ 编写的?我在https://github.com/nodejs/node 项目中寻找它们。

【问题讨论】:

    标签: javascript node.js require node-modules


    【解决方案1】:

    为了回答我自己的问题,我认为它是在loader.js 中定义的。您可以看到它已针对所有模块实现。 好像在node.js中映射到global.require

    【讨论】:

      【解决方案2】:

      This 似乎是它(node/lib/internal/modules/cjs/helpers.js)。

      【讨论】:

        猜你喜欢
        • 2011-11-14
        • 1970-01-01
        • 2016-02-21
        • 1970-01-01
        • 1970-01-01
        • 2012-02-15
        • 2023-02-19
        • 2020-06-14
        • 1970-01-01
        相关资源
        最近更新 更多