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
- Read a name from
process.argvand print a greeting with a sensible default. - Validate missing arguments and print a usage message.
- Read a text file with
fs/promises, then count lines, words and characters. - Handle a missing file with a clear error message and a non-zero exit code.
- 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.