process.mainModule


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

process.mainModule 属性提供了另一种检索 require.main 的方法。 不同之处在于,如果主模块在运行时发生更改,则 require.main 可能仍会引用更改发生前所需模块中的原始主模块。 通常,可以安全地假设两者指的是同一个模块。

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

Stability: 0 - Deprecated: Use require.main instead.

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.

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