Fork me on GitHub
vue.js

vue.js 运行环境的搭建(mac)

由于本人使用的是mac系统,因此在vue.js 的环境搭建上遇到许许多多的坑。感谢 showonne、yubang 技术指导,最终成功解决。下面是个人的搭建过程,权当是做个笔记吧。

 

 

 

由于mac非常人性化的将bash内置于终端中,因此可以直接在终端中使用bash命令。

 

 

 

     第一步: Mac OS系统安装 brew

 

     打开终端运行以下命令:

 

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 

     第二步: 安装 node.js

 

    为了避免使用brew命令经常出错的情况,所以采用手动安装  

 

    下载地址:https://nodejs.org/en/download/     (选择mac os)

 

 

 

  第三步: 获取nodejs模块安装目录访问权限  (必须步骤)

 

    sudo chmod -777 /usr/local/lib/node_modules/

 

 

 

       第四步: 安装 淘宝镜像 (cnpm)    

 

    npm install -g cnpm --registry=https://registry.npm.taobao.org

 

 

 

       第五步:安装webpack

 

   cnpm install webpack -g

 

  第六步:安装vue脚手架

 

    npm install vue-cli -g

 

 

 

  第七步:在硬盘上找一个文件夹放工程用的,在终端中进入该目录

 

    cd 目录路径

 

 

 

  第八步:创建一个vue.js工程

 

    vue init webpack-simple 工程名字<工程名字不能用中文>


 

  第九步:安装项目依赖

 

    一定要从官方仓库安装,npm 服务器在国外所以这一步安装速度会很慢。

 

    npm install     (慎用)

 

    cnpm install     (慎用)

 

 

 

  第十步:安装 vue 路由模块vue-router和网络请求模块vue-resource

 

    cnpm install vue-router vue-resource --save

 

  启动项目

 

    npm run dev

posted on 2017-05-02 21:32  HackerVirus  阅读(255)  评论(0编辑  收藏  举报