Vue学习 之 MacOS 安装 vue-cli
vue-cli 简介
vue-cli(Vue Command Line Interface)是Vue.js官方提供的一个脚手架工具,它提供了一些命令,可以帮助我们创建基于Vue.js的项目模板,快速开发Vue.js单页面应用(SPA)。使用vue-cli可以配置构建工具、插件、路由、状态管理等等,可以大大提升开发效率,减少重复操作。
vue-cli 安装
vue-cli 的安装需要先安装 Node.js 和 npm,建议先安装好 Node.js 和 npm 后再进行下面的安装步骤。
在命令行窗口中输入以下命令可以全局安装 vue-cli:
sudo npm install -g vue-cli
回车后需输入密码。
安装完成后可以通过以下命令验证是否安装成功:
vue -V
如果正确显示版本号,则说明安装成功。
完整步骤如下:
➜ ~ sudo npm install -g vue-cli
Password:
npm WARN deprecated vue-cli@2.9.6: This package has been deprecated in favour of @vue/cli
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 har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated consolidate@0.14.5: Please upgrade to consolidate v1.0.0+ as it has been modernized with several long-awaited fixes implemented. Maintenance is supported by Forward Email at https://forwardemail.net ; follow/watch https://github.com/ladjs/consolidate for updates and release changelog
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
added 234 packages in 15s
11 packages are looking for funding
run `npm fund` for details
➜ ~ vue -V
2.9.6
➜ ~
注意安装时需要使用 sudo npm install -g vue-cli
命令,使用其他命令可能会报权限错误的问题。