An example project to demonstrate the creation of a CLI using Node.js.
Building a CLI with Node.js in 2024
Below is the folder and file structure:
.
├── README.md
├── bin
│ └── index.js
├── package-lock.json
├── package.json
└── src
├── commands
│ ├── basic-example.js
│ ├── chalk-example.js
│ ├── figlet-example.js
│ ├── inquirer-confirm-example.js
│ ├── inquirer-example.js
│ ├── inquirer-list-example.js
│ └── ora-example.js
└── utils
Ensure you have Node.js installed on your computer
-
Clone the repository to your local machine using Git:
git clone https://github.com/egmzy/my-node-cli.git
-
Navigate to the project directory:
cd my-node-cli
-
Install the project dependencies:
npm install
-
Link the project globally to make the
my-node-cli
command available on your system:npm link
This step allows you to run the
my-node-cli
command from anywhere in your terminal.
After installation, you can run the CLI by typing my-node-cli
in your terminal. This command will display a list of examples that you can choose from, demonstrating various CLI functionalities:
- Basic Example
- Chalk Example
- Figlet Example
- Inquirer Confirm Example
- Inquirer Example
- Inquirer List Example
- Ora Example
Select an example to run it and see the functionality in action.
Contributions are welcome! Please feel free to fork the repository, make changes, and submit pull requests.