How does vue create a new project (detailed version)

The following steps are to create a new Vue project in detail:

1. First, install Node.js.

Enter at the command line node -vto check that Node.js is installed,
and use npm -vto check that npm is installed.
If you have not installed Node.js, go to the official Node.js website (https://nodejs.org/) to download and install it.

insert image description here
insert image description here

2. Install Vue CLI.

Vue CLI is a Node.js-based command-line tool for quickly building Vue projects.
Run the following command 检查 Vue CLI 的版本: If Vue CLI is successfully installed, the command line will display the version number of Vue CLI.

vue --version

If you don't have Vue CLI, run the following command 全局安装最新版本的 Vue CLI:

npm install -g @vue/cli

3. Create a new project.

From the command line, go to the directory where you want to create the project, and run the following command to create a new Vue project:

vue create vue  my-project

Here my-projectis the project name defined by yourself, which can be modified as needed.
After running the above command, Vue CLI will prompt you to choose a preset configuration.

  • If you are a beginner, you can choose the default configuration (default). Vue CLI will create a basic Vue project for you, including common configuration and plugins.
  • If you want to manually select features, you can choose to manually configure (Manually select features). Vue CLI will list a series of optional features and plugins, you can choose according to your needs. The space bar is to select and cancel, and the A key is to select all.

4. Wait for the project creation to complete.

Vue CLI will automatically download and install the dependencies required by the project, which may take some time. When the project is created, you will see a prompt similar to the following:

Project creation complete. To get started:

  cd my-project     // 进入到项目根目录
  npm run serve    // 启动项目

5. Enter the project directory.

On the command line, change into the project directory you just created:

cd my-project

6. Start the development server.

Run the following command to start the development server:

npm run serve

This will start a local development server and open your Vue application in the browser. You can develop while the development server is running and see the results of your changes in real time.

With this, you have successfully created a new Vue project and started the development server. You can modify and develop your Vue application as needed.

Guess you like

Origin blog.csdn.net/weixin_48596030/article/details/131829042