原因:
最后得出的原因是:版本太低!
vue的版本低于3x是没有ui功能的。
先查看版本号,输入命令:vue -V
再查看vue的帮助信息,有没有ui这个命令,输入命令:vue -h
> vue -V
2.9.6
> vue -h
Usage: vue <command> [options]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
init generate a new project from a template
list list available official templates
build prototype a new project
create (for v3 warning only)
help [cmd] display help for [cmd]
解决办法:
1、卸载老版本npm,Mac需要在命令前加上sudo管理员权限:
sudo npm uninstall vue-cli -g
2、卸载完后安装新的npm:
sudo npm install @vue/cli -g
再输入命令查看帮助就能看到ui命令了。
> vue -V
@vue/cli 4.5.13
> vue -h
Usage: vue <command> [options]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
create [options] <app-name> create a new project powered by vue-cli-service
add [options] <plugin> [pluginOptions] install a plugin and invoke its generator in an already created project
invoke [options] <plugin> [pluginOptions] invoke the generator of a plugin in an already created project
inspect [options] [paths...] inspect the webpack config in a project with vue-cli-service
serve [options] [entry] serve a .js or .vue file in development mode with zero config
build [options] [entry] build a .js or .vue file in production mode with zero config
ui [options] start and open the vue-cli ui
init [options] <template> <app-name> generate a project from a remote template (legacy API, requires @vue/cli-init)
config [options] [value] inspect and modify the config
outdated [options] (experimental) check for outdated vue cli service / plugins
upgrade [options] [plugin-name] (experimental) upgrade vue cli service / plugins
migrate [options] [plugin-name] (experimental) run migrator for an already-installed cli plugin
info print debugging information about your environment