Check required environment variables without leaking values.
You are required to build a CLI tool using Node.js that checks whether required environment variables are set.
Real projects use environment variables for values that change between machines, such as API keys, database URLs, and feature flags. Your CLI should accept environment variable names from the terminal and tell the user if any of them are missing.
Here are some example commands you can run to test your CLI:
On successful execution, the output should look like this:
If one or more environment variables are missing, print a friendly error:
If the user does not pass any names, print this error:
Errors should go to stderr, and the command should set a non-zero exit code.
Do not print the actual values of environment variables. Some of them may be secrets.
The goal of this project is to practice reading command arguments, using process.env, printing helpful errors, and avoiding accidental secret leaks in terminal output.
You will need these Node.js APIs:
process.argv to read the required environment variable names from the terminal.
process.env to check which environment variables are set for the current process.
process.exitCode to mark the command as failed without forcing an early crash.
Join the Community
roadmap.sh is the most starred project on GitHub and is visited by hundreds of thousands of developers every month.
Roadmaps Best Practices Guides Videos FAQs YouTube
roadmap.sh by @kamrify @kamrify
Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.
Login or Signup
You must be logged in to perform this action.