Skip to content

Node.js settings

November 16, 2023
December 11, 2014

Using nvm

creationix/nvm: Node Version Manager - Simple bash script to manage multiple active node.js versions
jorgebucaran/nvm.fish: Node.js version manager lovingly made for Fish.
nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
How to install and manage Node.js, sudo free, with NVM

curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
# nvm installer will load nvm in your shell profile

# use git repo
git clone git://github.com/creationix/nvm.git ~/.nvm
# you have to source nvm in your shell proflie
# echo ". ~/.nvm/nvm.sh" >> ~/.bashrc
. ~/.nvm/nvm.sh

Installing/updating Node.js

nvm ls # list local installed versions
nvm ls-remote # list remote versions

NODE_CURRENT=$(nvm current)
NODE_VERSION=v15  # new desired version
nvm install latest
# proper nvm
nvm alias default latest
nvm reinstall-packages ${NODE_CURRENT}
# nvm.fish
set --universal nvm_default_version (nvm current)

# add global module to NODE_PATH for require() to pick them up
NODE_PATH=$(npm root -g)

You have to reinstall all your global modules after update.
See Node modules or use nvm reinstall-packages <prev-version>.

Using Volta

Volta - The Hassle-Free JavaScript Tool Manager
Introducing Volta - it manages your Node.js versions so you don't have to -- newline

Using fnm

Schniz/fnm: 🚀 Fast and simple Node.js version manager, built in Rust

Using distro's package manager

This is the recommended way to install Node.js for daemons.

nodesource/distributions


An abbreviated history of JavaScript package managers
Understanding differences between npm, yarn and pnpm
Yarn determinism | Yarn Blog

Yarn

Yarn
Compare Yarn Performance | Yarn

Installing Node Packages with Yarn - How To - Cloud9 Community
Yarn: A new package manager for JavaScript | Engineering Blog | Facebook Code
Yarn vs npm - The State of Node.js Package Managers | @RisingStack

To Yarn and Back (to npm) Again | Mixmax Engineering Blog

Plug'n'Play | Yarn - Package Manager
PnP Overview | Yarn
Getting rid of node_modules with Yarn Plug’n’Play
Yarn Plug’n’Play – Thomas Reggi – Medium

Entropic

Entropic - we federate packages
entropic-dev/entropic: 🦝 a package registry for anything, but mostly javascript 🦝 🦝 🦝

pnpm

pnpm · Fast, disk space efficient package manager

Why I Switched From NPM/Yarn to PNPM And Why You Should Too! - YouTube
Life After Yarn - YouTube
Why should we use pnpm? by @ZoltanKochan
Flat node_modules is not the only way – pnpm – Medium
Why we switched from Yarn to pnpm - Data Orchestration for Composable Commerce

npm

npm is included in node since v0.6.3

The Ultimate Guide to Configuring NPM
npm Documentation
npm help 7 config
npm help npmrc

The npm Blog — Next Generation Package Management
npm Commands and Features You Should Know ← Alligator.io

sindresorhus/awesome-npm: Awesome npm resources and tips

Behind GFW

npm config set registry https://registry.npm.taobao.org

Disabling progress

Disabling progress with npm set progress=false yields faster npm install.
Faster npm

Project homepage

Use home to visit the homepage of a project hosted on NPM.

npm home nomnom
npm home lodash

npmrc without sudo

for system installs, not needed for nvm

guides/npm-global-without-sudo.md at main · sindresorhus/guides · GitHub
03 - Fixing npm permissions | npm Documentation

Add this to ~/.npmrc:

prefix = ${HOME}/.npm-packages

Then add this to ~/.profile or ~/.bashrc:

export PATH=${HOME}/.npm-packages/bin:$PATH

npx

npm/npx: npm package executor included in npm@5.2+
suarasaur/awesome-npx: 🌟 packages and resources that work really well with zkat/npx 🕶

Introducing npx: an npm package runner – Kat Marchán – Medium
How to use npx: the npm package runner
What is NPX?

Node modules

How to Solve the Global npm Module Dependency Problem

sverweij/dependency-cruiser: Validate and visualize dependencies. Your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.

module-alias - npm

node-gyp and Python 3

node-gyp does not supports Python 3, use these on system with Python 3 as default:

latest nvm supports command nvm reinstall-packages <old-version> to assist upgrade

Global modules:

# dev tools
npm install -g nesh nodemon
# project tools
npm install -g npm-check npm-remote-ls yarn
npx create-react-app fixpack
# linters
#  eslint-plugin-react
npm install -g jsonlint htmlhint prettier
# debug
npm install -g bench-rest node-inspector
# generators
# ionic yuidocjs
# npm install -g cordova
# doc tools
npm install -g bootprint bootprint-openapi dredd gitbook-cli raml1-doc ramlo
npm install -g doctoc markdown-tools
# data utils
npm install -g get-hrefs jq.node json pipeable-js yamljs
# servers
npm install -g serve fancy-server hotel json-server live-server
# bin
npm install -g rfc
# log tools
npm install -g bunyan logcat tap-spec faucet
# license tools
npm install -g license-generator license-sniffer license-spelunker

~/.script/ modules:

cd ~/.script
# lib modules
npm install chalk chance commander ip jsop nomnom lodash request
# automation
npm install cheerio revenant

# with package.json
npm install

List globally installed modules

To get a list for installing in another machine (or migration between Node version)

npm ls --location=global --depth 0
# OR
\ls $(npm root --location=global)

# shell independent
npm ls --location=global --depth 0 | grep -P '(?<= ).*(?=@)' -o | grep -v npm | tr '\n' ' ' && echo
# home
@google/clasp bunyan sslint fancy-server faucet fixpack github-commits-since-tag-cli hexo-cli htmlhint json jsonlint json-server licenseify live-server markdown-tools nodemon npm-check pipeable-js prettier pxt refine-manhuaren yarn

@google/clasp fixpack json-server licenseify nodemon prettier yarn

# work
csslint depcheck dredd ecstatic faucet fixpack htmlhint httpbin.js json jsonlint json-server licenseify live-server logcat markdown-tools netlify-cli nodemon prettier remarkable rfc tap-spec tldr typescript yamljs yarn

@google/clasp @leesei/imgmini bun corepack depcheck fixpack json-server licenseify nodemon prettier serve ts-node typescript yarn

npm fails

Try clearing npm cache with:

npm cache clean

Hope that helps.

when all else fails, clear you cache

Running Node alongside web servers

guides/run-node-server-alongside-apache.md at master · sindresorhus/guides


Packages

Chance
Papa Parse - Powerful CSV Parser for JavaScript
natergj/excel4node: Node module to allow for easy Excel file creation

bitinn/node-fetch: A light-weight module that brings window.fetch to Node.js Node.js supports this in v18.0.0

Voca: The JavaScript string library
panzerdp/voca: The ultimate JavaScript string library

alexreardon/memoize-one: A memoization library which only remembers the latest invocation

Release

vercel/pkg: Package your Node.js project into an executable

Introduction to snapshot flags in Node.js v18.8.0 - LogRocket Blog

Tokens

Unambiguous characters for token, good for OTP
Charset (base 30): "13456789ACDEFGHJKLMNPQRTUVWXYZ"

nanoid: Docs, Tutorials, Reviews | Openbase
Nano ID CC
ai/nanoid: A tiny (108 bytes), secure, URL-friendly, unique string ID generator for JavaScript
CyberAP/nanoid-dictionary: Predefined character sets to use with nanoid

chilts/node-coupon-code: Implementation of Perl's Algorithm::CouponCode for NodeJS

hirespace/token-gen: Generate unique human readable codes (e.g. vouchers, referrals, passwords, keys)

mcollina/hyperid: Uber-fast unique id generation, for Node.js and the browser
nwoltman/node-uid-generator: Generates cryptographically strong pseudo-random UIDs with custom size and base-encoding

lukeed/hexoid: A tiny (190B) and extremely fast utility to generate random IDs of fixed length
lukeed/uuid: A tiny (~230B)and fast UUID (V4) generator for Node and the browser

short-uuid: Docs, Tutorials, Reviews | Openbase

CLI

CLI argument parser

I need an option parser that auto generates the help page.

lukeed/sade: Smooth (CLI) Operator 🎶 built on mri

tj/commander.js: node.js command-line interfaces made easy quirky (might have improved since then):

util.parseArgs() | Node.js Documentation added v18.3.0, v16.17.0

import { parseArgs } from "node:util";
const { options, positionals } = parseArgs({
  options: {
    verbose: {
      type: "boolean",
      short: "v",
    },
  },
  allowPositionals: true,
});
console.log(options, positionals);
if (positionals.length === 0) {
  console.error("missing input");
  process.exit(1);
}

nodeca/argparse: CLI arguments parser for node.js. JS port of python's argparse module.
sindresorhus/meow: CLI app helper
hapijs/bossy: Command line options parser
leo/args: Minimal toolkit for building CLIs 😴inactive, built on mri
lukeed/mri: Quickly scan for CLI flags and arguments 😴inactive
75lb/command-line-args: A mature, feature-complete library to parse command-line options. 😴inactive

yargs/yargs: yargs the modern, pirate-themed successor to optimist. Docs
Yargs cheatsheet
I found yargs option are too complicated

scottcorgan/nash: Craft command-line masterpieces in Node.js 😴inactive
minimistjs/minimist: parse argument options naive, no help page
harthur-nomnom DEPRECATED
substack-node-optimist DEPRECATED, succeeded by yargs

CLI wrapper

google/zx: A tool for writing better scripts
JS-DevTools/ez-spawn: Simple, consistent, cross-platform process spawning
sindresorhus/execa: Process execution for humans
sindresorhus/dargs: Reverse minimist. Convert an object of options into an array of command-line arguments Reverse minimist
ShellJS
steelbrain/node-ssh: SSH2 with Promises

config files/env

davidtheclark/cosmiconfig: Find and load configuration from a package.json property, rc file, or CommonJS module
AdrieanKhisbe/configue: Configue All the Things.js
Env from T3
lorenwest/node-config: Node.js Application Configuration
indexzero-nconf load and merge config files
bevry/envfile
defunctzombie/localenv
motdotla/dotenv
zeke/local-env: Load your .env file into process.env

af/envalid: Environment variable validation for Node.js
dominictarr/rc: The non-configurable configuration loader for lazy people.
MoOx/rc-loader: Runtime configuration loader that supports YAML, JSON or JS.

frameworks

12 Factor CLI Apps – Jeff Dickey – Medium ❗!important
Build CLIs with an open framework using Node.js | oclif
Open Sourcing oclif, the CLI Framework that Powers Our CLIs | Heroku
CLI Flags in Practice + How to Make Your Own CLI Command with oclif | Heroku
Open CLI Framework: Create Command Line Tools Your Users Love - YouTube

weidagang-line-parser-js configuration over implementation
Omelette by f generates event from given command and you only have to implement the handlers
dscape-frameless event framework for CLI app
vdemedes-sushi Express for CLI

sub-shell

These allows you to build a sub-shell or yeoman-like app.

prompt
readline-sync
scottcorgan/nash: Craft command-line masterpieces in Node.js
scottcorgan/nash-usage: Help/usage display plugin for Nash command line masterpieces
tj/nshell: scriptable command-line shell written with node.js
enquirer/enquirer: Intuitive, plugin-based prompt system for node.js. Much faster alternative to Inquirer, with all the same prompt types and more.
SBoudrias/Inquirer.js: A collection of common interactive command line user interfaces.
anseki/readline-sync: Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).

dthree-vorpal create REPL
dthree-vantage

Terminal interface

The equivalent of ncurses in Linux.

chjj/blessed: A high-level terminal interface library for node.js.
substack/node-charm: ansi control sequences for terminal cursor hopping and colors
substack/terminal-menu: retro ansi terminal menus for serious 80s technicolor business

blessed derivative with markup support:
yaronn/wopr: A simple markup language for creating rich terminal reports, presentations and infographics
yaronn/blessed-contrib: Build terminal dashboards using ascii/ansi art and javascript
Yomguithereal/react-blessed: A react renderer for blessed.

madbence-node-drawille draw unicode braille characters
sindresorhus/sparkly

node-js-libs/cli: Rapidly build command line apps

vadimdemedes/pastel: 🎨 Framework for effortlessly building Ink apps
vadimdemedes/ink: 🌈 React for interactive command-line apps
Building rich command-line interfaces with Ink and React
Creating CLIs with Ink, React and a bit of magic
Add interactivity to your CLIs with React - LogRocket Blog

Text to ASCII Art Generator (TAAG)
patorjk/figlet.js: A FIG Driver written in JavaScript which aims to fully implement the FIGfont spec.

Home - voici.js data rendering

Workshop:
workshopper/workshopper
substack/adventure

Progress

sindresorhus/ora: Elegant terminal spinner
visionmedia/node-progress: Flexible ascii progress bar for nodejs
inikulin/elegant-status: Create elegant task status for CLI.
SamVerschueren/listr: Terminal task list

Colorizer

chalk/chalk: 🖍 Terminal string styling done right
jorgebucaran/clorox: Node.js library for colorizing text using ANSI escape sequences.
lukeed/kleur: The fastest Node.js library for formatting terminal text with ANSI colors~!
Marak/colors.js use chalk instead

danielb2-purdy.js colored object inspect

Logger

Requirements:

Comparing Node.js logging tools - LogRocket Blog 2021
NodeJS logging made right. Logging on steroids with CLS and Proxy | by Andrey Goncharov | ITNEXT 2019

trentm/node-bunyan 😴inactive
Bunyan JSON Logs with Fluentd and Graylog – The JS Blog

rvagg/bole based on idea of bunyan generally, simple yet flexible API

npm/npmlog: The logger that npm uses npm's logger

winstonjs/winston

nuxt/consola: 🐨 Elegant Console Logger
klauscfhq/signale: 👋 Hackable console logger fancy
bevry/caterpillar
debug-js/debug: A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers support DEBUG in env to toggle log
expressjs/morgan: HTTP request logger middleware for node.js 😴inactive, express's logger

Pino

Pino - Super fast, all natural JSON logger for Node.js
pinojs/pino: 🌲 super fast, all natural json logger

Ecosystem
feugy/pino-roll: A Pino transport that automatically rolls your log files

A Complete Guide to Pino Logging in Node.js | Better Stack Community
PINO - The fastest Node.js logger for production - NearForm 2016

File system

globbing

isaacs/node-glob: glob functionality for node.js
Understanding the glob pattern in Node.js - LogRocket Blog

mrmlnc/fast-glob: It's a very fast and efficient glob library for Node.js

JS-DevTools/readdir-enhanced: fs.readdir() with filter, recursion, absolute paths, promises, streams, and more!
JS-DevTools/file-path-filter: Filters file paths using globs, regular expressions, or custom criteria

micromatch/micromatch: Highly optimized wildcard and glob matching library. Faster, drop-in replacement to minimatch and multimatch. Used by square, webpack, babel core, yarn, jest, taro, bulma, browser-sync, documentation.js, stylelint, nyc, ava, and many others! Please follow micromatch's author: https://github.com/jonschlinkert
isaacs/minimatch: a glob matcher in javascript

sindresorhus/multimatch: Extends minimatch.match() with support for multiple patterns 😴inactive
sindresorhus/globby: User-friendly glob matching

file system watcher

gajus/turbowatch: Extremely fast file change detector and task orchestrator for Node.js.
paulmillr/chokidar: Minimal and efficient cross-platform file watching library
lukeed/watchlist: Recursively watch a list of directories & run a command on any file system changes 😴inactive
Conduitry/cheap-watch: If it works, why use something else? 😴inactive
Qard/onchange: Use glob patterns to watch file sets and run a command when anything is added, changed or deleted. 😴inactive

remy/nodemon: Monitor for any changes in your node.js application and automatically restart the server - perfect for development chokidar and minimatch
open-cli-tools/chokidar-cli: Fast cross-platform cli utility to watch file system changes

nodemon diagram.plantuml -x \"plantuml\"
nodemon diagram.png -x \"xdg-open\"
nodemon.js -e ts --exec tsc
nodemon --watch 'src/**/*.ts' --exec node --inspect -r ts-node/register src/server.ts

nodemon.json to monitor more file types:

{ "ext": "html,css,js,cjs,mjs,json,pug" }

Database/ORM

prisma
sql#ORM (or not)

I tried 8 different Postgres ORMs - YouTube
Top 11 Node.js ORMs, Query Builders & Database Libraries in 2021
The best TypeScript ORMs - LogRocket Blog
Which JavaScript ORM should you be using in 2018?
From TypeORM to LoopBack: A Retrospective – Hacker Noon

Schniz/cuery: A composable SQL query builder using template literals
Sequelize | The Node.js / io.js ORM for PostgreSQL, MySQL, SQLite and MSSQL

Knex.js - A SQL Query Builder for Javascript
Bookshelf.js built on Knex
Objection.js built on Knex

Kysely | Kysely inspred by Knex, model typing
kysely-org/kysely: A type-safe typescript SQL query builder

MikroORM: TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. | MikroORM

typeorm/typeorm: ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Setting up a basic TypeORM starter
TypeORM: Object-relational mapping with Node.js - LogRocket Blog

PlanetScale serverless driver for JavaScript — PlanetScale Documentation
planetscale/database-js: A Fetch API-compatible PlanetScale database driver fixes Prisma's slow cold start problem
Let's Talk About Database Performance - YouTube

Drizzel ORM

DrizzleORM - next gen TypeScript ORM
drizzle-team/drizzle-orm: TypeScript ORM for SQL Prisma alternative, less toolchain reliance

I Have A New Favorite Database Tool - YouTube
Drizzle ORM First impressions - migrations, relations, queries! - YouTube
This Drizzle ORM feature is a game changer! - YouTube