JavaScript + Node.js track

Part 7 · Mini Projects (Workbook)

Greeting CLI / File Stats Script

Greeting CLI / File Stats Script — Mini Projects (Workbook) in the free JavaScript + Node.js track, covering Node.js, fs, npm, package.json.

Mini Projects (Workbook)1 min readFree lesson

Project brief

Build a greeting CLI and a file-statistics script with Node.js. The projects practise command-line arguments, the file system and npm package metadata.

This is a workbook project in the JavaScript track. It has no single prescribed solution: build it in your own file, test it in the browser or Node, and compare your result with the checklist below.

What you will practise

  • Node.js
  • fs
  • npm
  • package.json

Build it step by step

  1. Read a name from process.argv and print a greeting with a sensible default.
  2. Validate missing arguments and print a usage message.
  3. Read a text file with fs/promises, then count lines, words and characters.
  4. Handle a missing file with a clear error message and a non-zero exit code.
  5. Add npm scripts for both tools and document them in package.json.

Stretch goal

Add one feature that is not in the list above, then write down why you chose it and what you had to change. Keep the feature small enough to finish in one sitting.

Before you move on

  • The project runs without errors in a fresh browser tab or Node process.
  • Empty, missing and invalid inputs are handled deliberately.
  • The code is split into small functions with clear names.
  • You can explain every line you wrote.

Topics: Node.js, fs, npm, package.json.

Assignment

Requirements

  • Use fs/promises rather than synchronous file calls.
  • Do not hard-code the file path; accept it as an argument.
  • Print a usage line when arguments are missing.
  • Set process.exitCode instead of calling process.exit() immediately.

Acceptance checklist

  • The happy path works end to end.
  • Invalid input produces a useful message, not a crash.
  • The code is readable and consistently formatted.
  • You have tested at least three different inputs.

Submission

Keep the project in a folder named after the project. Include a short README.md with run instructions and one paragraph describing what was hardest.

Learn this lesson with a mentor

Work through the JavaScript + Node.js track on your own, or join a guided cohort at our Pitampura campus and online.

Call NowEnroll Now