Each
.js
file is a
module
itself, which contains important information about the file. If we
console.log(module)
, it will print the following object:
Module {
  id: '.',
  path: '/home/runner/xrfnkv6ixs',
  exports: {},
  parent: null,
  filename: '/home/runner/xrfnkv6ixs/index.js',
  loaded: false,
  children: [],
  paths: [
    '/home/runner/xrfnkv6ixs/node_modules',
    '/home/runner/node_modules',
    '/home/node_modules',
    '/node_modules'
  ],
  _compile: [Function]
}
exports
key includes the content (variable / function / object) that's going to be publicly available for other modules
filename
key is equal to the module file location ...
by Valeri Tandilashvili
2 years ago
Node
Node.js Tutorial for Beginners - 1 Hour
0
Pro tip: use ```triple backticks around text``` to write in code fences