环境
Ubuntu 版本信息:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
Node.js 版本信息:
$ node --version
v16.15.0
$ npm --version
8.5.5
安装 Vue CLI
查看 Vue CLI 的最新版本:
$ npm view @vue/cli version
5.0.4
将 Vue CLI 模块安装到全局 node_modules 文件夹中:
$ npm install --global @vue/cli
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve
npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/
npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated apollo-cache-control@0.14.0: The functionality provided by the `apollo-cache-control` package is built in to `apollo-server-core` starting with Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/
npm WARN deprecated subscriptions-transport-ws@0.9.19: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/
npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
added 890 packages in 46s
执行命令 npm list -global 查看全局安装的模块:
$ npm list --global
/home/mk/Application/node-v16.15.0-linux-x64/lib
├── @vue/cli@5.0.4
├── corepack@0.10.0
└── npm@8.5.5
安装之后,你可以通过简单运行 vue ,看看其是否展示出了一份所有可用命令的帮助信息,来验证它是否安装成功:
$ vue
Command 'vue' not found, but can be installed with:
sudo snap install vue
你还可以用 vue --version 命令来检查其版本是否正确:
$ vue --version
Command 'vue' not found, but can be installed with:
sudo snap install vue
嗯,好尴尬,找不到命令!
我们尝试使用绝对路径访问 Vue CLI:
$ /home/mk/Application/node-v16.15.0-linux-x64/lib/node_modules/@vue/cli/bin/vue.js
Usage: vue <command> [options]
Options:
-V, --version output the version number
-h, --help display help for command
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 alias of "npm run serve" in the current project
build alias of "npm run build" in the current project
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
help [command] display help for command
Run vue <command> --help for detailed usage of given command.
使用绝对路径是可以访问 Vue CLI 的。
那么,我们可以为 Vue CLI 创建符号链接:
$ sudo ln -s /home/mk/Application/node-v16.15.0-linux-x64/lib/node_modules/@vue/cli/bin/vue.js /usr/local/bin/vue
创建符号链接之后,你可以在命令行中访问 vue --version 命令,查看 Vue CLI 版本信息:
$ vue --version
@vue/cli 5.0.4
你还可以访问 vue 命令,查看 Vue CLI 的用法:
$ vue
Usage: vue <command> [options]
Options:
-V, --version output the version number
-h, --help display help for command
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 alias of "npm run serve" in the current project
build alias of "npm run build" in the current project
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
help [command] display help for command
Run vue <command> --help for detailed usage of given command.
卸载
从全局文件夹中卸载 Vue CLI:
$ npm uninstall --global @vue/cli
removed 890 packages, and audited 1 package in 3s
found 0 vulnerabilities
新建项目
参考
Ubuntu 20.04.3 LTS - 安装 Node.js v16.14.2
Vue CLI 安装
Vue CLI 创建一个项目
ubuntu下安装vue-cli后输入vue提示无法找到vue命令解决办法
|