Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Vue CLI creates a project


May 07, 2021 Vue CLI


Table of contents


vue create

Run the following command to create a new project:

vue create hello-world

Warning

If you use Git Bash on Windows through minTTY, the interaction prompt doesn't work. Y ou must start this command with winpty vue.cmd create hello-world. H owever, if you still want to use vue create hello-world, you can add an alias to the command by adding the following lines to the .bashrc file. Alias vue'winpty vue.cmd' You need to restart the Git Bash terminal session for the updated bashrc file to take effect.

You will be prompted to choose a preset. You can choose the default preset that contains the basic Babel and ESLint settings, or you can choose the "manual selection feature" to select the required feature.

Vue CLI creates a project

This default setting is ideal for quickly creating prototypes for a new project, while manual settings provide more options that are more needed for production-oriented projects.

Vue CLI creates a project

If you decide to manually select an attribute, at the end of the action prompt you can choose to save the option as a future reusable preset. We'll discuss presets and plug-ins in the next section.

~/.vuerc

The saved preset will exist in the user's home directory next named .vuerc in the JSON file. If you want to modify the saved preset / option, you can edit this file.

During project creation, you will also be prompted to select your favorite package manager or use Taobao npm mirror source to install dependencies faster. These options will also be deposited in the ./.vuerc.

The vue create command has several options that you can explore by running the following command:

vue create --help
用法:create [options] <app-name>

创建一个由 `vue-cli-service` 提供支持的新项目


选项:

  -p, --preset <presetName>       忽略提示符并使用已保存的或远程的预设选项
  -d, --default                   忽略提示符并使用默认预设选项
  -i, --inlinePreset <json>       忽略提示符并使用内联的 JSON 字符串预设选项
  -m, --packageManager <command>  在安装依赖时使用指定的 npm 客户端
  -r, --registry <url>            在安装依赖时使用指定的 npm registry
  -g, --git [message]             强制 / 跳过 git 初始化,并可选的指定初始化提交信息
  -n, --no-git                    跳过 git 初始化
  -f, --force                     覆写目标目录可能存在的配置
  -c, --clone                     使用 git clone 获取远程预设选项
  -x, --proxy                     使用指定的代理创建项目
  -b, --bare                      创建项目时省略默认组件中的新手指导信息
  -h, --help                      输出使用帮助信息

Use a graphical interface

You can also create and manage projects in a graphical interface with the vue ui command:

vue ui

The above command opens a browser window and directs you through the process of project creation with a graphical interface.

Vue CLI creates a project

Pull 2.x template (older version)

The same vue command is used for the Vue CLI, so Vue CLI 2 (vue-cli) is overwritten. If you still need to use an older version of the vue init feature, you can install a bridging tool globally:

npm install -g @vue/cli-init
# `vue init` 的运行效果将会跟 `[email protected]` 相同
vue init webpack my-project