我使用Vue已经有一段时间了,但是我刚刚开始使用CLI,我有点困惑。
我安装了@vue/cli,如果我在命令行中输入vue,我得到:
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
upgrade [semverLevel] upgrade vue cli service / plugins (default semverLevel: minor)
info print debugging information about your environment
Run vue <command> --help for detailed usage of given command.我用vue创建了一个项目,由于一些我不记得的原因,我需要安装@vue/cli-service-global。
然而,在那之后,我注意到:
'vue-cli-service' is not recognized as an internal or external command这是因为我不得不安装@vue/cli-service。现在,当我在命令行中输入vue-cli-service时,我得到:
Usage: vue-cli-service <command> [options]
Commands:
serve start development server
build build for production
inspect inspect internal webpack config
run vue-cli-service help [command] for usage of a specific command.显然,我可以使用两个CLI工具构建、服务和检查。我的问题是-他们之间有什么区别?@vue/cli和@vue/cli-service的自述文件除了链接到此页之外,什么都没有,在链接中,没有给出这个问题的答案。
我能用一个我不能用另一个做什么?我两者都需要吗?
发布于 2019-01-18 07:03:12
@vue/cli-service-global是一个包,允许您运行vue serve和vue build,而不需要任何本地依赖项。
@vue/cli-service是一个实际执行vue serve和vue build的包,@vue/cli-service-global和@vue/cli都依赖于它们。
如果使用的是@vue/cli,则不需要独立安装另外两个,因为它的依赖项中已经包含了@vue/cli-service。
补充道:只是想确定一下,我会更详细地解释它:
@vue/cli
add、create、config、ui和其他命令build和serve命令通过@vue/cli-service-global包inspect包执行@vue/cli-service命令(本地依赖项)@vue/cli-service-global
build、inspect和serve命令通过@vue/cli-service包@vue/cli-service
build、inspect和serve命令因此,您只需要安装@vue/cli并删除另外两个。
补充说:澄清了如何使用vue-cli-service:当您使用vue create命令创建项目时,@vue/cli会在创建的项目的./node_modules/.bin中创建一个指向vue-cli-service二进制文件的链接。
然后你可以像这样使用它:
vue-cli-service直接访问npm脚本(package.json):
“脚本”:{“观看”:"vue-cli-service build“}./node_modules/.bin/vue-cli-service build --watch。您甚至可以将./node_modules/.bin添加到您的shell PATH中,并以vue-cli-service的形式从shell直接访问它。https://stackoverflow.com/questions/54248678
复制相似问题