FANDOM


Language

API

Node 10.x LTS

Module/Object Type Description Remarks
Crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. Certifacate, Cipher, Decipher, DiffieHellman, EDCH, Hash, Hmac
Global Objects
Global Object Type Description Remarks
__dirname string The directory name of the current module. appear to be global but is not
console Object Used to print to stdout and stderr.
module Object A reference to the current module. appear to be global but is not
process Object provides information about, and control over, the current Node.js process.
require() Function Used to import modules, JSON, and local files. appear to be global but is not

Node 8.x LTS

Module/Object Type Description Remarks
File System module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions
Process object provides information about, and control over, the current Node.js process.
Console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
HTTP module HTTP server and client
http.Server class inherits net.Server
Net module provides an asynchronous network API for creating stream-based TCP or IPC servers and clients
net.Server module used to create a TCP or IPC server

Node 4.x

JavaScript

OOP

  • Classes
  • Getting started with Node.js modules: require, exports, imports and beyond (August 12th 2016)
    • Use exports to:
      • Export named function. e.g. exports.area, exports.circunference
    • Use module.exports to:
      • If you want to export an object, class, function at the root level e.g. module.exports = Cat
      • If you want to return a single object that exposes multiple assignments. e.g. module.exports = {area: area, circumference: circunference};

Debugging

misc

Frameworks

MVC

Express

Testing

Mocha

Readings
Constructor Option CLI Option Type Description Remarks
asyncOnly --async-only, -A boolean Require all tests to use a callback (async) or return a Promise
bail --bail, -b boolean Bail after first test failure?
fullTrace --full-trace boolean Full stacktrace upon failure?
reporter --reporter, -R string | constructor Reporter name or constructor
timeout --timeout, -t, --timeouts string Specify test timeout threshold (in milliseconds) default: 2000
ui --ui, -u string Specify user interface default: "bdd"

Libraries

Language

node-iconv

  • iconv (Wikipedia)
    • a computer program and a standardized application programming interface (API) used to convert between different character encodings.

iconv-lite

urlencode

node-time

node-formidable

EJS

Parsing

JS-YAML

Commander.js

Logging

winston

morgan

Web

generator

express-session

cookie-parser

bent

Security

Passport

Run

nodemon

forever

PM2

Misc

Nodemailer

Tools

npm

  • https://www.npmjs.org/
  • Desc. : official package manager for Node.js
  • License : the Artistic License 2.0
  • Written in : JavaScript

References

  • The location of npm configuration files (npmrc or .npmrc)
    • $ npm config ls
Scope O/S File Remarks
Built-in Linux path-to-npm/npmrc
Windows path-to-nodejs/npm_modules/npm/npmrc
Global Linux $PREFIX/etc/npmrc --globalconfig, $NPM_CONFIG_GLOBALCONFIG
Windows $USERPROFILE\AppData\Roaming\npm\etc\npmrc C:\Users\username\AppData\Roaming\npm\etc\npmrc
User Linux $HOME/.npmrc --userconfig, $NPM_CONFIG_USERCONFIG
Project path-to-project/.npmrc

Semantic Versioning

  • npm-semver: The semantic versioner for npm
    • hyphen ranges : x.y.z - a.b.c
    • x-ranges : 1.2.x 1.X 1.2.* *
    • tilde ranges : ~1.2.3 ~1.2 ~1
    • caret ranges : ^1.2.3 ^0.2.5 ^0.0.4
  • Tilde Ranges
    • Allows patch-level changes if a minor version is specified on the comparator. Allows minor-level changes if not.
    • Allows (upwards) changes in least meaningful level.
~1.2.3        := >=1.2.3 <1.3.0
~1.2          := >=1.2.0 <1.3.0 (Same as 1.2.x)
~1            := >=1.0.0 <2.0.0 (Same as 1.x)
~0.2.3        := >=0.2.3 <0.3.0
~0.2          := >=0.2.0 <0.3.0 (Same as 0.2.x)
~0            := >=0.0.0 <1.0.0 (Same as 0.x)
~1.2.3-beta.2 := >=1.2.3-beta.2 <1.3.0
  • Caret Ranges
    • Allows changes that do not modify the left-most non-zero digit
    • Allows (upwards) changes except the most meaningful level.
^1.2.3        := >=1.2.3 <2.0.0   (the most meaningful : 1)
^0.2.3        := >=0.2.3 <0.3.0   (the most meaningful : 2)
^0.0.3        := >=0.0.3 <0.0.4   (the most meaningful : 3)
^1.2.3-beta.2 := >=1.2.3-beta.2 <2.0.0   (the most meaningful : 1)
^0.0.3-beta   := >=0.0.3-beta <0.0.4     (the most meaningful : 3)
^1.2.x        := >=1.2.0 <2.0.0   (the most meaningful : 1)
^0.0.x        := >=0.0.0 <0.1.0   (the most meaningful : 2nd 0)
^0.0          := >=0.0.0 <0.1.0   (the most meaningful : 2nd 0)
^1.x          := >=1.0.0 <2.0.0
^0.x          := >=0.0.0 <1.0.0

Package Configuration

Option Description Remarks
engines Specify the version of node that your stuff works on

Commands

Command Description Aliases Remarks
npm ls List installed packages npm list, npm ll
npm ls -g -depth 0 List global packages without dependencies.
npm view View registry info shows data about a package and prints it to the stream referenced by the outfd config, which defaults to stdout.
npm install Install a package
npm update Update all the packages listed to the latest version (specified by the tag config), respecting semver
npm uninstall Uninstalls a package, completely removing everything npm installed on its behalf. npm rm
npm prune Removes "extraneous" packages
npm config Manage the npm configuration files npm c
npm config set <key> <value> Sets the config key to the value.
npm config get <key> Echo the config value to stdout
npm config list Show all the config settings.
npm prefix Print the local/global prefix to standard out
npm rebuild Runs the npm build command on the matched folders. npm rb

Samples

$ # list explicitly defined configuration by scope and file
$ npm config ls

$ # list all the npm configuration in json format
$ npm config ls -l --json

$ # upgrade npm to the latest version
$ npm install -g npm@latest

$ # upgrade npm to the most recent release
$ npm install -g npm@next

$ # view details of the package
$ npm view web3

Readings

nvm

  • https://github.com/creationix/nvm
  • Desc. : Node Version Manager - Simple bash script to manage multiple active node.js versions
  • License : The MIT License
  • Written in :

nodist

n

nodenv

node-gyp

  • https://github.com/nodejs/node-gyp
  • Desc. : a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js.
  • License : MIT license
  • Written in : JavaScript

Readings

Community content is available under CC-BY-SA unless otherwise noted.