Javascript 全局函数上下文

Javascript 全局函数上下文,javascript,node.js,Javascript,Node.js,我创建了一个名为run()的函数,但在module.export的上下文中找不到它。存储此函数的上下文是什么 function run(){ function run2(){ console.log(this === global) console.log(this === module) } run2() } con

我创建了一个名为
run()
的函数,但在
module.export的上下文中找不到它。存储此函数的上下文是什么

    function run(){


            function run2(){
                console.log(this === global)
                console.log(this === module)
            }

            run2()

        }




  console.log(module.exports)

上下文是全局的。您必须导出它才能在
模块中找到它。导出
对象

试试这个

module.exports.run = function() {
    function run2() {
        console.log(this === global)
        console.log(this === module)
    }

    run2()

}

console.log(module.exports)

您没有将它添加到
模块。导出
,为什么会在那里?