VUE安装及初始化报错解决办法

1、安装淘宝镜

由于 npm 安装速度慢,本教程使用了淘宝的镜像及其命令 cnpm

 安装淘宝镜像
$ npm:npm install -g cnpm --registry=https://registry.npm.taobao.org
 
# 升级 npm
$ cnpm install npm -g

2、安装vue服务

$ cnpm install vue

3、命令行工具

Vue.js 提供一个官方命令行工具,可用于快速搭建大型单页应用。

1)# 全局安装 vue-cli
$ cnpm install --global vue-cli

2)# 下载webpack离线安装包
$ https://github.com/vuejs-templates/webpack.git

3)# 在用户目录下查看是否有.vue-templates目录,没有的,则创建
# (文件名命名:文件名之后加点 即.vue-templates.回车就是需要的)
# 命令行:cd users/HP(其中HP是电脑用户名,根据实际情况选择);makir .vue-templates

4)# 离线模板创建项目:
$ vue init webpack my-project --offline

# 这里需要进行一些配置,默认回车即可
This will install Vue 2.x version of the template.

For Vue 1.x use: vue init webpack#1.0 my-project

? Project name my-project
? Project description A Vue.js project
? Author runoob <test@runoob.com>
? Vue build standalone
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? Yes

   vue-cli · Generated "my-project".

   To get started:
   
     cd my-project
     npm install
     npm run dev
   
   Documentation can be found at https://vuejs-templates.github.io/webpack

4、启动项目

进入项目,安装并运行:
$ cd my-project
$ cnpm install
$ cnpm run dev
 DONE  Compiled successfully in 4388ms

> Listening at http://localhost:8081

 

posted @ 2020-04-30 10:58  叫我大表哥  阅读(1260)  评论(0编辑  收藏  举报