Building a CLI Tool with Node.js in 2026: From Zero to npm Publish
I built 5 CLI tools last year. Here's the exact setup I use every time.
Why Node.js for CLIs?
One language for your whole stack (frontend + backend + CLI)
npm ecosystem — thousands of packages to leverage
Cross-platform — works on Mac, Linux, Windows
Fast enough — V8 is fast, startup time is acceptable
Familiar — if you know JS/TS, you can build CLIs
The Setup
mkdir my-cli && cd my-cli npm init -y
# Core dependencies (my go-to stack): npm install commander inquirer chalk ora figlet update-notifier npm install -D typescript @types/node tsx esbuild
Enter fullscreen mode
Exit fullscreen mode
Package Purpose
commander Argument parsing, subcommands
inquirer Interactive prompts
chalk Terminal colors
ora Spinners/loading indicators
figlet ASCII art banners
update-notifier Notify users of updates
Project Structure
my-cli/ ├── src/ │ ├── index.ts # Entry point (bin) │ ├── commands/ │ │ ├── init.ts # my-cli init │ │ ├── deploy.ts #…