skip to content

How do you start a new Vue 3 project with create-vue, and why must the command be npm create vue@latest rather than npm create vue?

level: juniorimportance: must knowfreq 35%

answer

  1. the official Vite-based scaffolder
  2. a version tag on the command
  3. prompts, then files
  4. it does not install
  5. legacy is Vue 2

basics

~10 s

Run npm create vue@latest, answer the prompts, then install dependencies and start the dev server. The @latest tag matters because without it npm may reuse a cached, outdated create-vue.

solid answer

~40 s

`npm create vue@latest` runs the create-vue package, the official scaffolder for Vite-powered Vue projects. It asks for a project name, whether to use TypeScript (default yes), and a multiselect of JSX, Router, Pinia, Vitest, end-to-end testing, ESLint and Prettier, then writes the files. It does not install anything: it prints the next steps, such as `cd`, `npm install` and `npm run dev`. The README says the `@latest` (or `@legacy`) tag must not be omitted, because npm may otherwise resolve a cached, outdated version. `npm create vue@legacy` scaffolds Vue 2, which has reached end of life. Unlike Vue CLI, create-vue is only a scaffolder: the result is a plain Vite project.

code

bash · 4 lines
bash
npm create vue@latest
cd vue-project
npm install
npm run dev

go deeper

for a junior

Recall the command npm create vue@latest, the TypeScript and feature prompts, and the install and dev steps you run afterwards.

for a middle

Explain that create-vue writes a plain Vite project and exits, why the @latest tag matters, and what the Node engine range is.

for a senior

Show you would standardise scaffolding on create-vue with explicit flags and a pinned Node version, and never start new work from @legacy or Vue CLI.

for a principal

Decide whether teams scaffold directly from create-vue or from an internal template built on it, weighing freshness against house conventions.

## What create-vue is **create-vue** is the official tool for starting a Vue 3 application. It is a **scaffolder**: it asks a few questions, writes a project into a folder, and exits. The project it writes is a normal **Vite** project with the Vue plugin, so everything after scaffolding, from the dev server to the production build, is Vite's job. That is the main difference from Vue CLI, which was webpack-based and stayed in the loop as a build tool. ## Running it 1. Check Node: create-vue 3.24 and the projects it writes declare `node ^22.18.0 || >=24.12.0`. 2. Run `npm create vue@latest`. `npm create vue` maps to the `create-vue` package; the `@latest` tag makes npm fetch the current release instead of a cached one, which the README marks as mandatory. 3. Answer the prompts, or pass flags to skip them. 4. Follow the printed steps: `cd` into the folder, install dependencies, and start the dev server. If formatting was chosen, it also suggests running the format script once. 5. If the folder is not already a git repository, it suggests a `git init` and a first commit. ## The prompts, in order | Prompt | Default | Notes | |---|---|---| | Project name | `vue-project` | skipped when you pass a directory | | Overwrite a non-empty folder? | no | skipped with `--force` | | Use TypeScript? | yes | | | Features | none | JSX, Router, Pinia, Vitest, End-to-End Testing, ESLint, Prettier | | E2E framework | none | only if E2E was picked: Playwright or Cypress | | Experimental features | none | Oxfmt, Vue 3.6 release candidate, tsgo | | Skip example code? | no | the 'barebone' option | ## What you get With TypeScript, Router and Pinia, the project contains: - `index.html`, `vite.config.ts` with the Vue plugin, the Vue DevTools plugin and an `@` alias for `src`; - `src/main.ts`, which creates the app and installs Pinia and the router; - `src/App.vue`, example components and views, `src/router/index.ts` and `src/stores/counter.ts`; - a set of `tsconfig` files and an `env.d.ts`; - `package.json` scripts `dev`, `build` and `preview`, plus scripts for each tool you picked. The generated `package.json` pins current majors: Vue 3.5, Vite 8, and, when chosen, Vue Router 5.3 and Pinia 4. ## The last two prompts - **Experimental features** is a second multiselect. **Oxfmt** replaces Prettier as the formatter, **Vue 3.6 release candidate** opts into the next minor before it is stable, and **tsgo** swaps the `typescript` package for the native TypeScript bridge; tsgo is only offered when TypeScript is on. Choosing the release candidate or tsgo adds a package-manager question, because the scaffolder writes version overrides in that manager's format. - **Skip example code?** is the barebone option, default no. Yes keeps all the tooling but removes the welcome components, empties the routes array and leaves a minimal `App.vue`. For a team's first internal tool, the usual answers are TypeScript, Router, Pinia, Vitest and ESLint, no experimental features, and barebone once the team no longer needs the example code as a reference. ## A snapshot, not a dependency create-vue is not added to the project's dependencies. The files it writes are yours from the first commit, and later upgrades of Vue, Vite or the router happen through your package manager, not by running the scaffolder again. Re-running it into an existing folder asks to overwrite that folder, which is a way to lose work, not to upgrade. ## Mistakes worth catching - **Omitting `@latest`.** The README warns npm may resolve a cached, outdated create-vue. - **Reaching for Vue CLI.** New projects start from create-vue; Vue CLI is the webpack-era tool it replaced. - **Expecting installed dependencies.** Nothing is installed until you run your package manager. - **Using `@legacy` for a new app.** It scaffolds Vue 2, which is past end of life, and exists only for projects that must support old browsers.

  • How is create-vue different from Vue CLI?
    Vue CLI was webpack-based and stayed involved as the build tool. create-vue is only a scaffolder: it writes a preconfigured Vite project and exits, so the dev server, build and plugins are Vite's, and the project can use Vite plugins directly.
  • What does npm create vue@legacy produce, and when is it justified?
    It scaffolds a Vue 2 project. The README keeps it for teams that must support very old browsers such as IE11, and warns that Vue 2 has reached end of life, so it is not a starting point for new work.
  • What does the --default flag scaffold?
    A project with no optional features and no feature prompts, but with TypeScript on: in the 3.24 source `--default` is one of the flags that turn TypeScript on, matching the interactive default of yes.

create-vue is like a flat-pack kit's assembly sheet rather than a builder who stays on site: it lays out the pieces you ordered in the right places and leaves, and from then on the house is yours and Vite's to run.

saying these in an interview costs you the question

  • npm create vue without @latest always gets the newest scaffolder.
  • create-vue installs the dependencies before it exits.
  • New Vue 3 projects should start from Vue CLI.
  • create-vue stays in the project as its build tool.
  • npm create vue@legacy is the stable option for new apps.