環境
Deepin15.4
注:①文中提到的路徑都要根據自己實際路徑進行修改 ②非Linux用戶跳過<設置軟連接>部分 ③cnpm作用與npm一致,只是cnpm下載國內資源,下載更快一下
下載及配置
node下載地址:http://nodejs.cn/download/
解壓到文件夾 /home/maskerk/vue/ 下
設置軟連接:
$ ln -s /home/maskerk/vue/bin/node /usr/local/bin
$ ln -s /home/maskerk/vue/bin/npm /usr/local/bin
執行命令
$ node -v
$ npm -v
顯示正常說明設置成功
安裝cnpm
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
//設置軟連接
$ ln -s /home/maskerk/vue/bin/cnpm /usr/local/bin
安裝vue
$ cnpm install vue
//設置軟連接
$ ln -s /home/maskerk/vue/bin/vue /usr/local/bin
全局安裝 vue-cli
$ cnpm install --global vue-cli
創建新工程
# 創建一個基於 webpack 模板的新項目
$ vue init webpack my-project
# 這里需要進行一些配置,默認回車即可
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
進入項目,安裝所需支持並運行
$ cd my-project
$ cnpm install
啟動項目
$ cnpm run dev
出現類似 DONE Compiled successfully in 4388ms,即啟動成功
Listening at http://localhost:8080
打開網址 http://localhost:8080

錯誤處理
在執行'''cnpm install'''命令時,出現錯誤‘webpack-dev-server不是內部或外部命令’
處理方法: cnpm install webpack-dev-server
執行"cnpm install"出現錯誤
處理方法:
方案一:
cnpm rebuild node-sass
#不放心可以重新安裝下
cnpm install
方案二:
npm update
npm install
nodejs node_modules/node-sass/scripts/install.js
npm rebuild node-sass
一般只要執行方案一就夠了。
然后再運行,OK。
使用 style lang="stylus" 報錯
解決方法

"此時不僅僅需要cnpm install stylus-loader.還需要cnpm install stylus " 這兩步基本就可以解決了
vue打包后element-ui部分樣式(圖標)異常問題
https://www.cnblogs.com/ljwsyt/p/11579370.html
vue 打包后頁面空白



