1、安装vue需要安装nodejs,先去nodejs官网下载nodejs,https://nodejs.org/en/download/
(ps:由于安装vue时,npm install -g vue-cli下载镜像很慢,用淘宝的镜像npm install -g cnpm --registry=https://registry.npm.taobao.org安装只支持v.6.11.2,所以下载版本6.11.2,nodejs6.11.2版本链接:https://nodejs.org/en/blog/release/v6.11.2/ )
2.wget https://nodejs.org/dist/v6.11.2/node-v6.11.2-linux-x64.tar.xz

由于是.xz压缩包,解压方法:
(2-1):xz node-v6.11.2-linux-x64.tar.xz 解压成 node-v6.11.2-linux-x64.tar
(2-2):tar xvf node-v6.11.2-linux-x64.tar解压
3、要想全局使用node、npm命令,创建软连接
(3-1):ln -s /usr/loca/src/node-v6.11.2-linux-x64/bin/node /usr/local/bin/node
(3-2):ln -s /usr/loca/src/node-v6.11.2-linux-x64/bin/npm /usr/local/bin/npm
(3-3):node -v 和npm -v显示

4、安装vue-cli脚手架
(4-1):npm install -g cnpm--registry=https://registry.npm.taobao.org

(4-2):cnpm -v

ps:这是由于cnpm不是全局命令,解决方法
ln -s /usr/local/src/node-v6.11.2-linux-x64/bin/cnpm /usr/local/bin/cnpm
(4-3):cnpm -v

(4-4):cnpm install -g vue-cli

(4-5):vue

(4-6):原因vue不是全局命令,解决方法,创建软连接
ln -s /usr/local/src/node-v6.11.2-linux-x64/bin/vue /usr/local/bin/vue
(4-7):vue

5、vue list

6、vue install webpack vue_project (你的项目名字)
(6-1):?Project description (A Vue.js project) vue-cli新建项目(项目描述);
(6-2):? Author (xhdx ) ;xxxx@sina.com(项目作者);
(6-3):? Vue build
❯ Runtime + Compiler: recommended for most users
Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere
(6-4):? Install vue-router? (Y/n) y是否使用vue-router,这里根据需求选择;
(6-5):? Use ESLint to lint your code? (Y/n) y是否使用ESLint,这里根据需求选择;
(6-6):? Pick an ESLint preset (Use arrow keys)
❯ Standard (https://github.com/feross/standard)
Airbnb (https://github.com/airbnb/javascript) none (configure it yourself)这里选择Standard (https://github.com/feross/standard)
(6-7):? Setup unit tests with Karma + Mocha? (Y/n) n是否需要单元测试,这里根据需求选择;
(6-8):Setup e2e tests with Nightwatch? (Y/n) n是否需要单元测试,这里根据需求选择;
(6-9):cnpm install安装依赖;(ps:npm install安装镜像慢,改为cnpm install 安装);
(6-10):npm run dev本地运行项目
由于每个人的机器环境和对linux和vue了解不一样,需要耐心安装调试vue-cli
网友评论