• {module}

    Module 对象,表示当 Node.js 进程启动时加载的入口脚本。 参见[访问主模块]。

    entry.js 脚本中:

    1. console.log(require.main);
    1. node entry.js
    1. Module {
    2. id: '.',
    3. path: '/absolute/path/to',
    4. exports: {},
    5. parent: null,
    6. filename: '/absolute/path/to/entry.js',
    7. loaded: false,
    8. children: [],
    9. paths:
    10. [ '/absolute/path/to/node_modules',
    11. '/absolute/path/node_modules',
    12. '/absolute/node_modules',
    13. '/node_modules' ] }