Monday, March 26, 2018

NodeJS - REPL - List all built in modules

To list all built in modules using nodejs REPL.

$ node
> var myRepl = require('repl');null;
null
> myRepl._builtinLibs;
[ 'assert',
  'async_hooks',
  'buffer',
  'child_process',
  'cluster',
  'crypto',
  'dgram',
  'dns',
  'domain',
  'events',
  'fs',
  'http',
  'https',
  'net',
  'os',
  'path',
  'perf_hooks',
  'punycode',
  'querystring',
  'readline',
  'repl',
  'stream',
  'string_decoder',
  'tls',
  'tty',
  'url',
  'util',
  'v8',
  'vm',
  'zlib',
  'http2' ]

> .exit
 $ 


There is another way to list the builtin modules without opening the Nodejs repl. Run the following command at your linux terminal:

$ node -pe "require('repl')._builtinLibs"
[ 'assert',
  'async_hooks',
  'buffer',
  'child_process',
  'cluster',
  'crypto',
  'dgram',
  'dns',
  'domain',
  'events',
  'fs',
  'http',
  'https',
  'net',
  'os',
  'path',
  'perf_hooks',
  'punycode',
  'querystring',
  'readline',
  'repl',
  'stream',
  'string_decoder',
  'tls',
  'tty',
  'url',
  'util',
  'v8',
  'vm',
  'zlib',
  'http2' ]
$

This I learnt from the answer posted at stackoverflow:


2 comments:

  1. yours blog was excellent and really enjoyed.Thanks for sharing and mainting blogging. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site. Really the post is very unique.every concepts are captured nice.

    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore



    ReplyDelete