
Learn what CLIs are, how common tools support a Vue workflow, and how to build a Node.js CLI that reads input, generates files, and runs as a command.
Reza Baar
November 17, 2026
Every Vue project starts the same way: you open a terminal and type a command. Before you write a single component, you're already using a CLI. For something so central to the daily workflow, the command line is often treated as a set of incantations you copy from a tutorial without really knowing what's happening. In this post, we'll clear that up. We'll cover what a CLI actually is, the CLI tools you use in a Vue project, and what it means to build one yourself.
CLI stands for command line interface. It's a way of interacting with a program by typing text commands instead of clicking buttons in a graphical interface (a GUI). You type a command, press enter, the program does something, and it prints text back.
A command usually has three parts. Take this one:
npm install vue --save-dev
npm is the program you're running.install and vue are arguments: the input you're giving the program. Here they say "install, and the thing to install is vue."-save-dev is a flag (also called an option): a setting that changes how the command behaves. Flags usually start with - for the long form or a single for a short form.
That structure (program, arguments, flags) is consistent across almost every CLI tool you'll touch. Once you recognize it, a long unfamiliar command becomes readable: you can pick out what program is running, what you're asking it to do, and which settings are turned on.If GUIs are friendlier, why do developers live in the terminal? A few reasons that matter in practice.
Commands are exact and repeatable. "Run npm run build" is unambiguous, where "click Build, then pick Production from the dropdown" depends on a UI that changes. That precision is why setup instructions, documentation, and tutorials are written as commands.
Commands can be automated. Anything you type in a terminal can be saved into a script and run again, or run by a CI/CD pipeline with no human present. The deploy that happens when you push to your repo is running the same commands you'd type by hand.
Commands compose. You can chain tools together, feed the output of one into another, and build small workflows out of single-purpose programs. A GUI gives you the buttons its designer chose; the terminal gives you the pieces.
And they're fast. Once you know the command, typing npm run dev is quicker than navigating menus. For things you do dozens of times a day, that adds up.
You don't need to know every CLI tool in existence. As a Vue developer, a handful come up constantly. Let's go through the ones you would use.
Node.js is the JavaScript runtime that everything else runs on, and it comes with npm (Node Package Manager), the tool that installs and manages your project's dependencies. When you run npm install, npm reads your package.json, downloads the packages it lists, and puts them in node_modules.
# Install everything listed in package.json
npm install
# Add a new dependency
npm install pinia
# Add a dev-only dependency
npm install -D vitest
npm also runs the scripts defined in your package.json. In a Vue project, those scripts are the commands you run most:
# Start the dev server
npm run dev
# Build for production
npm run build
npx runs a package without installing it permanently. This is handy for one-off tools you don't want cluttering your global setup. It downloads the package, runs it, and moves on. We'll see it again in a moment with scaffolding.
When you start a new Vue project, you use create-vue, the official scaffolding tool. You run it through npm:
npm create vue@latest
This downloads and runs create-vue (you don't install it globally), and it walks you through a series of questions: project name, whether you want TypeScript, Vue Router, Pinia, a testing setup, ESLint, and so on. Based on your answers, it generates a ready-to-go project with those features wired in. Keep the @latest on the end, since without it npm may run a cached, outdated version.
A create-vue project is powered by Vite, and the npm run dev and npm run build scripts are really calling Vite's CLI under the hood. If you open the package.json in a scaffolded project, you'll see something like:
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}
So npm run dev runs vite, which starts the dev server. npm run build runs vite build, which produces your production bundle. You're using the Vite CLI every day; it's just wrapped in an npm script.
git is the version control tool you use to track changes, branch, and collaborate. It's a CLI tool like the rest, with the same command-argument-flag structure:
git add .
git commit -m "Add user profile page"
git push origin main
Together, these tools are the backbone of a Vue developer's day: scaffold with create-vue, install with npm, develop and build with Vite, version with git. All text commands, all following the same pattern.
To pull it all together, let’s look at an example. When you run npm create vue@latest and it asks you about TypeScript and Router and Pinia, then generates a project, that is a CLI app doing its work. So what is it actually doing?
A CLI app is just a program that does four things: it reads the arguments and flags you passed, optionally prompts you for more input, does some work, and prints output (plus an exit code that signals success or failure). create-vue reads your project name, prompts you for features, generates files based on your answers, and prints next steps. Strip away the polish and that's the whole shape.
Let's build a small one to make it concrete. We'll make a tiny Vue-flavored CLI: a tool that generates a new Vue component file from a name you give it. This is a miniature version of what scaffolding tools do.
Create a file called make-component.mjs. The first thing our tool needs is the component name the user passed. Node gives you the command's arguments in process.argv:
// make-component.mjs — reads the component name from the command arguments
const name = process.argv[2];
if (!name) {
console.error('Please provide a component name.');
console.error('Usage: node make-component.mjs MyComponent');
process.exit(1);
}
console.log(`Creating component: ${name}`);
process.argv is an array where the first two entries are the path to Node and the path to your script, so the actual arguments start at index 2. If no name is given, we print an error and call process.exit(1). The 1 is a non-zero exit code, which signals failure. A 0 means success. This is how other tools and CI pipelines know whether your command worked.
Run it:
node make-component.mjs UserCard
# Creating component: UserCard
Now let's actually generate a component file. We'll write out a minimal Vue single-file component using the name:
// make-component.mjs — generates a .vue file from a template
import { writeFile } from 'node:fs/promises';
const name = process.argv[2];
if (!name) {
console.error('Please provide a component name.');
process.exit(1);
}
const template = `<script setup lang="ts">
// ${name} component
</script>
<template>
<div class="${name.toLowerCase()}">
<!-- ${name} -->
</div>
</template>
`;
const filename = `${name}.vue`;
await writeFile(filename, template);
console.log(`Created ${filename}`);
Run it and you get a real file:
node make-component.mjs UserCard
# Created UserCard.vue
That's a working CLI app. It reads an argument, does work (writes a file from a template), and prints output. The core idea behind every scaffolding tool is right there, just scaled down.
The tools you use, like create-vue, don't just take arguments; they ask you questions interactively. Node has a built-in way to do this through the readline module, no extra packages needed. Here's our tool asking whether to include a <style> block:
// make-component.mjs — prompts the user for an option, then generates accordingly
import { writeFile } from 'node:fs/promises';
import { createInterface } from 'node:readline/promises';
const rl = createInterface({ input: process.stdin, output: process.stdout });
const name = await rl.question('Component name? ');
const answer = await rl.question('Include a scoped style block? (y/n) ');
rl.close();
const withStyle = answer.toLowerCase() === 'y';
let template = `<script setup lang="ts">
// ${name} component
</script>
<template>
<div class="${name.toLowerCase()}"></div>
</template>
`;
if (withStyle) {
template += `
<style scoped>
.${name.toLowerCase()} {
}
</style>
`;
}
await writeFile(`${name}.vue`, template);
console.log(`Created ${name}.vue`);
Now the tool asks for the name and whether to include styles, the same interactive pattern you see when create-vue asks about TypeScript and Router. The underlying idea is identical; create-vue just has more questions and generates a whole project instead of one file.
One last piece connects this back to the tools we covered. Right now you run the tool with node make-component.mjs. Real CLI tools run as their own command (like vite or eslint). Two things make that happen.
First, a shebang line at the top of the file tells the system to run it with Node:
#!/usr/bin/env node
// the rest of your script follows
Second, a bin field in package.json maps a command name to your file:
{
"name": "make-component",
"bin": {
"make-component": "./make-component.mjs"
}
}
With those in place, when the package is installed, make-component becomes a command you can run directly. This is exactly how vite, eslint, and create-vue become runnable commands: each is a Node script with a shebang and a bin entry. The tools you use every day are built on the same mechanism as the 30-line script we just wrote.
npm run dev and npm run build are npm scripts that call the Vite CLI under the hoodprocess.argv, the fs module, and a prompts librarybin field in package.json is what turns a script into a runnable command, the same way create-vue and Vite workThe command line stops being a set of magic incantations once you see the pattern underneath it. Every tool you use in a Vue project follows the same structure, and every one of them, from Vite to create-vue, is a program that reads input, does work, and prints output. Building a small CLI yourself is the fastest way to internalize that, and as a bonus, a component generator like the one we built is genuinely useful in a real project.
I hope this post has been helpful. Please let me know if you have any questions or comments. Happy coding!
Ready to prove your Vue.js skills?
Get certified in Vue.jsKeep learning Vue.js. Then get certified when you are ready.

A Reference to Composable Patterns in Vue
A catalog of practical patterns for writing composables that are flexible, predictable, and easy to reuse.
Reza Baar

Structuring a Large Vue App: A Feature-Based Folder Architecture
Why the default components/composables/stores split breaks down at scale, and how a feature-first structure fixes it.
Reza Baar

Tighter TypeScript in <script setup>
How Vue sharpened TypeScript support for defineProps, defineEmits, defineModel, and defineSlots, and how to write clearer component contracts.
Reza Baar