Lesson PackCreated by the roadmap.sh team

Build CLI Apps with Node.js

Learn how to build practical CLI apps with Node.js and npm

21Lessons9Projects2.7 hours read

What's Inside

  1. 01

    CLIs and the Terminal

    Learn what CLI apps are and how terminal commands work.

    4 mins
  2. 02

    Your First Node.js Script

    Run JavaScript with Node.js and build a small system-info script.

    6 mins
  3. 03

    Creating a Node Project

    Create a Node.js project with package.json, scripts, and ES modules.

    Free6 mins
  4. 04

    Modules in Node.js

    Split a Node.js CLI across files with ES module imports.

    6 mins
  5. 05

    Built-in Node Modules

    Use built-in Node modules for system info, paths, and files.

    Free8 mins
  6. 06

    npm Packages

    Install npm packages and import them into a Node.js CLI.

    Free6 mins
  7. 07

    Reading Command Arguments

    Read terminal arguments with process.argv and npm scripts.

    7 mins
  8. 08

    Flags and Options

    Add flags, option values, defaults, and help text to a CLI.

    9 mins
  9. 09

    CLI Libraries and Subcommands

    Use Commander to build subcommands, options, and help output.

    8 mins
  10. 10

    Interactive Prompts

    Ask terminal questions with prompts and use answers in a CLI.

    7 mins
  11. 11

    Making a Real Command

    Turn a Node.js project into a command that runs by name.

    9 mins
  12. 12

    Output, Errors, and Exit Codes

    Route output, errors, and exit codes for a reliable CLI.

    7 mins
  13. 13

    Handling Failures Well

    Handle expected mistakes and unexpected bugs without messy crashes.

    8 mins
  14. 14

    Reading Files

    Read files from a CLI and handle common path errors.

    8 mins
  15. 15

    Writing Files and Folders

    Write files and create folders from a Node.js CLI.

    11 mins
  16. 16

    JSON Storage

    Store structured CLI data in a local JSON file.

    10 mins
  17. 17

    Pipes and Redirects

    Make a CLI work with stdin, stdout, stderr, pipes, and redirects.

    Free7 mins
  18. 18

    Config and Environment Variables

    Read config files and environment variables in a CLI.

    11 mins
  19. 19

    Calling APIs from a CLI

    Call an API from a CLI and format the JSON response.

    11 mins
  20. 20

    Running Other Commands

    Run Git from Node.js with child processes and capture output.

    10 mins
  21. 21

    Capstone: Build and Polish a CLI

    Build a multi-command CLI from the course pieces.

    5 mins

What you'll learn

  • Build useful terminal tools with Node.js
  • Give your commands a name using npm
  • Args, flags, prompts, config, env, and pipes
  • Read and write files, folders, and JSON data
  • Call APIs and run Git from your CLI
  • Best practices for creating CLI applications

Meet the Author

Kamran Ahmed

Kamran is the founder of roadmap.sh and works on it full-time. Over the past decade he's shipped across startups and scale-ups, with most of his work in open source, he's a Google Developer Expert, a GitHub Star, and the second-most-starred developer on GitHub globally.

What are Lesson Packs?

Lesson packs are premium, opinionated guides written by the team. Pro members get access to all current and future lesson packs, including other pro benefits.

  • Written by the team behind roadmap.sh
  • Visual diagrams and real examples
  • A clear, opinionated path per roadmap
  • Unlocks every current and future pack

RoadmapsGuidesFAQsYouTube

roadmap.shby@nilbuild

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

© roadmap.sh·Terms·Privacy·

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.