安装Node
Node的安装在此就不多说了。
设置npm
安装node时,默认已经安装了包管理器npm,可以输入npm -v查看npm版本。可以输如npm -g install npm更新npm到最新版本。 npm自带的源是国外的,下载太慢,可以通过以下命令切换到国内源
npm config set registry https://registry.npm.taobao.org
也可以安装nrm,用于快速切换npm源
npm -g install nrm
列出可用的源
kevinmeng@MacBook-Pro ~ % nrm ls
npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
cnpm ------- http://r.cnpmjs.org/
* taobao ----- https://registry.npm.taobao.org/
nj --------- https://registry.nodejitsu.com/
npmMirror -- https://skimdb.npmjs.com/registry/
edunpm ----- http://registry.enpmjs.org/
切换源
kevinmeng@MacBook-Pro ~ % nrm use taobao
Registry has been set to: https://registry.npm.taobao.org/
安装vue脚手架
npm install -g @vue/cli
...
vue -v
注:这里@代表最新版
创建Vue项目
创建Vue项目非常简单,通过Vue UI创建即可
kevinmeng@MacBook-Pro ~ % vue ui
🚀 Starting GUI...
🌠 Ready on http://localhost:8000
浏览器打开http://localhost:8000创建VUE项目即可。
启动Vue项目
创建好vue项目后,进入项目所在目录,运行以下命令启动项目项目即可。
yarn serve
#也可以指定端口
yran serve --port 8105
评论区