开发环境
node.js 10.12.0,npm 6.9.0/cnpm 6.0.0 , webpack 3.12.0 ,vue 2.9.6, webstorm 11.0.4
Mac系统 环境安装
1.安装 brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
2.安装 nodejs
brew install nodejs
node自带npm npm install npm@6.9.0更新版本
通过node -v / npm -v 检查是否安装成功
mac需要给npm目录授权
sudo chmod -R 777 /usr/local/lib/node_modules/
3. 安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
淘宝镜像 优点比npm安装速度要快, 用法一样
4. 安装webpack
cnpm install webpack -g
webpack -v 检查是否安装成功 查看版本号
5. 安装vue脚手架
npm install vue-cli -g
vue -V 检查是否安装成功
6. 安装WebStorm,VSCode,HBuilderX 自行百度
初始化vue项目
新建目录
创建目录:cd 目录路径
初始化: vue init webpack-simple projectname
过程:
$ vue init webpack projectname --------------------- 安装vue-cli的命令
This will install Vue 2.x version of the template.
For Vue 1.x use: vue init webpack#1.0 projectname
? Project name (projectname)
? Project name projectname
? Project description (A Vue.js project)
? Project description A Vue.js project
? Author Joe --------------------- 项目创建者
? Author Joe
? Vue build (Use arrow keys)
? Vue build standalone
? Install vue-router? (Y/n) --------------------- 是否安装Vue路由
? Install vue-router? Yes
? Use ESLint to lint your code? (Y/n) n ---------------------是否启用ESLint
? Use ESLint to lint your code? No
? Setup unit tests with Karma + Mocha? (Y/n)
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? (Y/n)
? Setup e2e tests with Nightwatch? Yes
vue-cli · Generated "projectname".
To get started: --------------------- 这里说明后续的三个步骤
cd projectname -------------------进入项目
npm install -------------------安装依赖
npm run dev -------------------运行开发环境