← Back to all tutorials

The Vue CLI

Set up a professional Vue development environment with the Vue CLI — scaffolding, webpack, hot reload, and single-file components.

The Vue CLI

So far you have been using Vue via a CDN script tag. For real applications, the Vue CLI (Command Line Interface) provides a full development environment with a build system, hot reload, linting, and single-file components.

What the Vue CLI Provides

FeatureBenefit
Webpack buildBundles, minifies, and optimizes your code
Hot module reloadChanges appear instantly without a full page refresh
ES6+ supportBabel transpiles modern JavaScript for older browsers
.vue filesSingle-file components with template, script, and style
LintingESLint catches errors and enforces code style
Dev serverServes your app locally with live reload

Installing the Vue CLI

npm install -g @vue/cli

vue --version
// @vue/cli 5.x.x

Creating a Project

vue create my-project

The CLI asks you to pick a preset. For learning, choose "Default (Vue 2)" or manually select features. It scaffolds the project and installs dependencies automatically.

Project Structure

my-project/
├── node_modules/
├── public/
│   ├── index.html         (the HTML shell)
│   └── favicon.ico
├── src/
│   ├── App.vue            (root component)
│   ├── main.js            (entry point)
│   ├── assets/            (images, fonts)
│   └── components/        (reusable components)
├── package.json
└── babel.config.js

Running the Project

cd my-project
npm run serve

The dev server starts (usually on port 8080) with hot reload. Edit any .vue file and the browser updates instantly.

Build Commands

CommandPurpose
npm run serveStart the development server
npm run buildBuild for production (outputs to dist/)
npm run lintRun ESLint to check code quality

Key Takeaways

  • The Vue CLI provides a full development environment with webpack, Babel, and hot reload
  • vue create project-name scaffolds a new Vue project
  • npm run serve starts the dev server; npm run build creates a production bundle
  • Single-file components (.vue files) combine template, script, and style in one file