🎓 A1Learner
🔍
0 of 50 lessons completed

Setting Up Vue with Vite

Vite builds a starter Vue project in one command. This course uses Vite 6.4.6 with Vue 3.5.45.

Check Node.js

This command prints the Node.js version.

node --version

Create the project

This command creates a project named my-vue-app.

npm create vue@latest my-vue-app

Install and run

These commands move into the folder, install the files, and start the project.

cd my-vue-app
npm install
npm run dev

Use the full Vue build

Add this setting to vite.config.js inside defineConfig.

export default defineConfig({
  plugins: [vue()],
  resolve: { alias: { vue: 'vue/dist/vue.esm-bundler.js' } },
})

Example

<template>
  <div>
    <h1>Welcome to Vue</h1>
    <p>My first Vue page.</p>
  </div>
</template>

Key points

  • A project is one folder with every file one app needs.
  • An app is a small program that runs in the browser.
  • Vite needs Node.js, which runs JavaScript outside a browser.
  • npm is a tool that installs JavaScript packages.
  • Vite needs one small setting so components in the same file work.
  • Real projects usually put each component in its own file. A separate file needs no setting.

In this example, the page shows a heading. The heading reads Welcome to Vue. A short line follows the heading. The line reads My first Vue page. Vite shows this file once the project starts.

Note

Copy the create command exactly and press Enter.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which command creates a new Vue project with Vite?