Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Vue 3 Creating a Project

Vue 3 Creating a Project

In the previous chapter Vue 3 Installation we used the npm init command to create a project; in this chapter we mainly introduce the npm create command to create a project and the vue ui command to open a graphical installation interface.

The recommended IDE setup for Vue development is Visual Studio Code + Vue - Official extension:

Other IDE support is as follows:


The npm create Command

Use the npm create command to create a Vue project, typically via Vite (Vue's officially recommended build tool).

In Vite, npm create is used to run a scaffolding tool (such as vite@latest) to quickly generate a new project template.

For Vite details, refer to:Vite Tutorial.

The syntax format for creating a project with the npm create command is as follows:

npm create vite@latest  --template vue

Explanation:

Next we create the runoob-vue3-app project:

npm create vite@latest

Running the above command will prompt you to enter a project name and select a framework:

> Project name: … runoob-vue3-app

? Select a framework: › - Use arrow-keys. Return to submit.

❯   Vanilla

    Vue

    React

    Preact

    Lit

    Svelte

    Solid

    Qwik

    Angular

    Others

Vite supports multiple templates; common ones are:

You can use the arrow keys to select; we choose Vue, then an option-variant screen appears where we can choose JavaScript Quick Start:



> Project name: … runoob-vue3-app

> Select a framework: › Vue

> Select a variant: › JavaScript



Scaffolding project in /Users/runoob/runoob-test/runoob-vue3-app...



Done. Now run:



  cd runoob-vue3-app

  npm install

  npm run dev



After installation, we enter the project directory:

cd runoob-vue3-app

The entire directory structure is shown below:

Install dependencies and start the application:



npm install

npm run dev

Then open http://localhost:5173/to see the application interface:

Additionally, we can set our own port in the vite.config.js file, for example setting it to 3000 as follows:

Example

import

{

defineConfig

}

from

'vite'

import

vue from

'@vitejs/plugin-vue'

// https://vite.dev/config/

export

default

defineConfig

(

{

  plugins

:

[

vue

(

)

]

,

  server

:

{

    port

:

3000

,

// Your own specified port number

 

}

,

}

)


The vue ui Command

Besides using the vue create command to create a project, we can also use a visual creation tool to create a project.

Run the command:



$ vue ui

->  Starting GUI...

->  Ready on http://localhost:8000

...

Running the above command pops up a project management interface in the browser:

We can click the **"Create"** option to create a project, choose "Create here" at the bottom, and select a path at the top of the page:

Then enter our project name, select npm as the package manager, and click Next:

For configuration, just choose the default:

Then wait for the installation to complete; the completed management interface is as follows: