I am looking for a way to get an exact up-to-date list of all Node.js core modules. Is there an NPM module that supplies such a running list? Somewhere in the annals of my life
If you don't mind accessing underscore-prefixed properties, repl
exports a _builtinLibs
array:
$ node -pe "require('repl')._builtinLibs" [ 'assert', 'buffer', 'child_process', 'cluster', 'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'net', 'os', 'path', 'punycode', 'querystring', 'readline', 'stream', 'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib' ]
That list isn't as "complete" as the list provided by the builtin-modules
module in that it does not include undocumented and similar modules.
33 modules are in the builtin-modules according to https://www.npmjs.com/package/builtin-modules.
36 according to core structures
28 repositories in Git
112 packages
It will take a long time to compile this list. Doing it as a research on node_core will be good option.
console.log ( require('repl')._builtinLibs ); return;
to list all built-in modules.
J4F: you can use the github api and get a list of files directly in JSON format.
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()
As of Node v9.3.0, you just do this:
require("module").builtinModules
[ 'async_hooks',
'assert',
'buffer',
'child_process',
'console',
'constants',
'crypto',
'cluster',
'dgram',
'dns',
'domain',
'events',
'fs',
'http',
'http2',
'_http_agent',
'_http_client',
'_http_common',
'_http_incoming',
'_http_outgoing',
'_http_server',
'https',
'inspector',
'module',
'net',
'os',
'path',
'perf_hooks',
'process',
'punycode',
'querystring',
'readline',
'repl',
'stream',
'_stream_readable',
'_stream_writable',
'_stream_duplex',
'_stream_transform',
'_stream_passthrough',
'_stream_wrap',
'string_decoder',
'sys',
'timers',
'tls',
'_tls_common',
'_tls_legacy',
'_tls_wrap',
'tty',
'url',
'util',
'v8',
'vm',
'zlib',
'v8/tools/splaytree',
'v8/tools/codemap',
'v8/tools/consarray',
'v8/tools/csvparser',
'v8/tools/profile',
'v8/tools/profile_view',
'v8/tools/logreader',
'v8/tools/tickprocessor',
'v8/tools/SourceMap',
'v8/tools/tickprocessor-driver',
'node-inspect/lib/_inspect',
'node-inspect/lib/internal/inspect_client',
'node-inspect/lib/internal/inspect_repl' ]
see https://nodejs.org/api/modules.html#modules_module_builtinmodules