process.mainModule


稳定性: 0 - 弃用:请改用 require.main

process.mainModule 属性提供了一种获取 require.main 的替代方法。区别在于,如果主模块在运行时发生变化,require.main 可能仍然指向在变化发生之前被引用的原始主模块。通常,可以认为这两个指向的是同一个模块。

【The process.mainModule property provides an alternative way of retrieving require.main. The difference is that if the main module changes at runtime, require.main may still refer to the original main module in modules that were required before the change occurred. Generally, it's safe to assume that the two refer to the same module.】

require.main 一样,如果没有入口脚本,process.mainModule 将是 undefined

【As with require.main, process.mainModule will be undefined if there is no entry script.】