Installing Node on Linux


If you change the installed folder to be only writable by root, install modules globally using sudo as follows, avoiding attempting to follow symlinks:

$ sudo PATH=$PATH -E \
/usr/local/lib/nodejs/node-$NODE_VERSION-linux-x64/lib/node_modules/npm/bin/npm-cli.js \
install -g yarn

Installing on macOS

Node can be installed using MacPorts. E.g.

$ sudo port install nodejs12

Build Distribution Tar File

$ ./configure
$ make binary

Note: compiling Node on a Raspberry Pi 1 model B took over 9 hours.

Application Development

Getting Started

Documenting Your Code


npm init creates some default scripts.

Installing packages

$ npm install PACKAGE-NAME --save

If the package is only required for development, use --save-dev instead of --save.

If the package is on GitHub, you can reference it as:

npm install <githubname>/<githubrepo>[#<commit-ish>]

See NPM cli for more detailed information.

Useful Packages

  • body-parser - Node.js body parsing middleware
  • bcrypt - Lib to help you hash passwords
  • Connect - An extensible HTTP server framework for node using "plugins" known as middleware
  • copyfiles
  • debug - A tiny node.js debugging utility modelled after node core's debugging technique
  • formidable - A Node.js module for parsing form data, especially file uploads
  • jsonwebtoken - An implementation of JSON Web Tokens
  • lodash - A modern JavaScript utility library delivering modularity, performance, & extras
  • Router - Simple middleware-style router
  • nconf - Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging
  • node-2fa - Easy 2-Factor Integration For Node.JS
  • node-autoquit - Automatically quit node.js servers when inactive
  • node-pool - Generic resource pool with Promise based API
  • node-postgres - Non-blocking PostgreSQL client for node.js
  • node-systemd - support for running node.js as a socket-activated service under systemd
  • node-uuid - Simple, fast generation of RFC4122 UUIDs.
    Note: Original implementation no longer maintained - - see for further details.
  • nodemon - Monitor for any changes in your node.js application and automatically restart the server
  • qs - A querystring parsing and stringifying library with some added security
  • sax-js - A sax-style parser for XML and HTML
  • sendmail - Send mail without SMTP server
  • serve-favicon - Node.js middleware for serving a favicon
  • ShellJS - Unix shell commands for Node.js
  • smtp-protocol Write smtp clients and servers
  • Turfjs - a JavaScript library for spatial analysis
  • xmlbuilder-js - An XML builder for node.js similar to java-xmlbuilder
  • UglifyJS2 - UglifyJS is a JavaScript parser, minifier, compressor or beautifier toolkit
  • winston - A multi-transport async logging library for node.js. "CHILL WINSTON! ... I put it in the logs."

Interesting Projects

  • Blob.js - implements the W3C Blob interface in browsers that do not natively support it
  • body-parser - Parse incoming request bodies in a middleware before your handlers, available under the req.body property
  • node-cssmin - A little node module that minimize CSS Files
  • dgeni - Flexible JavaScript documentation generator used by AngularJS, Protractor and other JS projects
  • electron - The Electron framework lets you write cross-platform desktop applications using JavaScript, HTML and CSS
  • qs - A querystring parsing and stringifying library with some added security
  • Rough.js - A light weight (~9kB gzipped) graphics library that lets you draw in a sketchy, hand-drawn-like, style
  • Speakeasy - a one-time passcode generator, ideal for use in two-factor authentication, that supports Google Authenticator and other two-factor devices

Installing Yarn


Installing on macOS

Yarn can be installed using MacPorts. E.g.

$ sudo port install yarn

Building a tarball package

$ yarn pack

Using Yarn Offline

Yarn Selective Dependency Resolution

LTS schedule

Uninstalling Node.js

On macOS, if Node.js was installed via a package, it can be removed by deleting the files listed in /var/db/receipts/ The files can be listed by using the lsbom utility.

$ lsbom -f -l -s -pf /var/db/receipts/

The file names are relative to the /usr/local/ directory.

Additionally, consider removing the following under /usr/local/:

  • /usr/local/lib/node_modules/
  • /usr/local/include/node/
  • /usr/local/share/doc/node/
  • /var/db/receipts/org.nodejs.node.pkg.*

See for more information.

Build Tools


See also:


-- Frank Dean - 24 Mar 2016

Related Topics: AngularJS, DevelopmentSetup, DockerTips, LinuxDevelopment