节点核心模块的确切列表

我正在寻找一种方法来获取所有Node.js核心模块的最新列表。 是否有一个NPM模块提供这样的运行列表? 在我生命中的某个地方,我已经回答了这个问题,但是我不记得它,也没有记得它有多好。

如果您不介意访问以下划线为前缀的属性,则repl导出一个_builtinLibs数组:

 $ node -pe“require('repl')._ builtinLibs”
 ['assert',
   '缓冲',
   'child_process',
   '簇',
   “密码”,
   'DGRAM',
   'DNS',
   '域',
   “事件”,
   'FS',
   'HTTP',
   'https' 时,
   '净',
   'OS',
   'path',
   'Punycode码',
   '请求参数',
   '的ReadLine',
   'stream',
   'string_decoder',
   'TLS',
   'TTY',
   'URL',
   'UTIL',
   'V8引擎',
   “虚拟机”,
   'zlib']

该列表不像“ builtin-modules模块提供的列表那样“完整”,因为它不包括未logging的和类似的模块。

J4F:你可以使用github api并直接获取JSON格式的文件列表。

 var http = require('https') var path = require('path') var options = { hostname: 'api.github.com', path: '/repos/nodejs/node/contents/lib', method: 'GET', headers: { 'Content-Type': 'application/json', 'user-agent': 'nodejs/node' } } var req = http.request(options, (res) => { res.setEncoding('utf8') var body = "" res.on('data', (data) => { body += data }) res.on('end', () => { var list = [] body = JSON.parse(body) body.forEach( (f) => { if (f.type === 'file' && f.name[0]!=='_' && f.name[0]!=='.') { list.push(path.basename(f.name,'.js')) } }) console.log(list) }) }) req.on('error', (e) => { throw (e) } ) req.end() 

根据https://www.npmjs.com/package/builtin-modules,33个模块位于内置模块中。

 36 according to core structures 28 repositories in Git 112 packages 

编制这份清单需要很长时间。 把它作为node_core的研究将是不错的select。