1.基本環境搭建
安裝Node.js和npm
首先,從Node.js官網下載對應平臺的安裝程式,在Windows上安裝時務必選擇全部元件,包括勾選Add to Path,npm已經在Node.js安裝的時候順帶裝好了.
C:\Users\Hugo>node -v
v10.14.1
C:\Users\Hugo>npm -v
6.4.1
安裝Yarn
C:\Users\Hugo>npm install -g yarn
C:\Users\Hugo>yarn -v
1.12.3
國內源映象加速
C:\Users\Hugo>yarn config set registry https://registry.npm.taobao.org
yarn config v1.12.3
success Set "registry" to "https://registry.npm.taobao.org".
Done in 0.03s.
新增模組
C:\Users\Hugo>yarn add chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
安裝vue-cli
C:\Users\Hugo>yarn global add vue-cli
vue命令還無法使用,需要進行path配置
C:\Users\Hugo>yarn global dir
C:\Users\Hugo\AppData\Local\Yarn\Data\global
將C:\Users\Hugo\AppData\Local\Yarn\bin加入path
就可以使用vue命令了
C:\Users\Hugo>vue
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]