詳細版:
一、nodejs的安裝
Node.js安裝包及源碼下載地址為:https://nodejs.org/en/download/。

我們可以根據不同平台系統選擇你需要的Node.js安裝包。Node.js 歷史版本下載地址:https://nodejs.org/dist/
這里演示的是Window64位安裝Node.js,下面演示的是采用安裝包的方式來安裝。
1、Windows 安裝包(.msi)
Node.js默認安裝目錄為 "C:\Program Files\nodejs\" , 你可以修改目錄,並點擊 next(下一步):
:點擊 Install(安裝) 開始安裝Node.js。你也可以點擊 Back(返回)來修改先前的配置。 然后並點擊 next(下一步):
安裝完之后啟動cmd依次執行以下兩條命令檢測是否安裝成功,結果如下:

二、node.js的環境變量的新建。 //我安裝的路徑是 D:\soft\nodejs
其實安裝完node,就自動在path里增加環境變量,但是為了以后的本地部署項目,我們需要找到node.js的安裝根目錄,在當中新建“node_global”和"node_cache"兩個文件夾。
1、 啟動cmd依次執行以下兩條命令
npm config set prefix " D:\soft\nodejs\node_global"
npm config set cache " D:\soft\nodejs\node_cache"
2、 設置環境變量
說明:設置環境變量可以使得住任意目錄下都可以使用cnpm、vue等命令,而不需要輸入全路徑
1.鼠標右鍵"此電腦",選擇“屬性”菜單,在彈出的“系統”對話框中左側選擇“高級系統設置”,彈出“系統屬性”對話框。
2.點擊環境變量彈出下列對話框:
3.新增系統變量NODE_PATH:把變量值設置成“D:\soft\nodejs\node_global\node_modules” (這樣就可以把后面全局安裝的裝到global里並且可以直接用命令使用。)
4. 修改用戶變量PATH:選中PATH,點擊編輯,把“D:\soft\nodejs\node_global;”加到前面
三、安裝淘寶的npm鏡像
輸入npm install -g cnpm –registry=https://registry.npm.taobao.org,即可安裝npm鏡像,以后再用到npm的地方直接用cnpm來代替就好了。
這個其實看個人愛好吧,因為npm在國內下載速度是很慢,所以就用npm下載安裝cnpm可以更快的下載后面的依賴等等。
四、安裝全局vue-cli腳手架、webpack
命令輸入
cnpm install vue –g //全局安裝vue
cnpm install -g vue-cli //全局安裝vue-cli
cnpm install -g webpack //全局安裝webpack
cnpm install -g webpack-dev-server //安裝webpack的本地webserver
安裝完成后,vue-cli腳手架其實就已經把vue也裝掉了,所以只需輸入vue -V 和 webpack -v 等等就可以查看安裝成功與否。
下面是以上命令的結果:
$ npm install vue -g
E:\nodejs\node_global
`-- vue@2.4.4
$ npm install -g vue-cli
E:\nodejs\node_global\vue-init -> E:\nodejs\node_global\node_modules\vue-cli\bin\vue-init
E:\nodejs\node_global\vue-list -> E:\nodejs\node_global\node_modules\vue-cli\bin\vue-list
E:\nodejs\node_global\vue -> E:\nodejs\node_global\node_modules\vue-cli\bin\vue
E:\nodejs\node_global
`-- vue-cli@2.9.1
+-- async@2.5.0
| `-- lodash@4.17.4
+-- chalk@2.1.0
..... 此處省略很多結果數據 .....
$ npm install webpack -g
E:\nodejs\node_global\webpack -> E:\nodejs\node_global\node_modules\webpack\bin\webpack.js
> uglifyjs-webpack-plugin@0.4.6 postinstall E:\nodejs\node_global\node_modules\webpack\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js
E:\nodejs\node_global
`-- webpack@3.7.1
+-- acorn@5.1.2
+-- acorn-dynamic-import@2.0.2
.....此處省略多行數據.......
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\webpack\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
$ npm install -g webpack-dev-server
E:\nodejs\node_global\webpack-dev-server -> E:\nodejs\node_global\node_modules\webpack-dev-server\bin\webpack-dev-server.js
E:\nodejs\node_global
+-- UNMET PEER DEPENDENCY webpack@^2.2.0 || ^3.0.0
`-- webpack-dev-server@2.9.1
+-- ansi-html@0.0.7
+-- array-includes@3.0.3
.....此處省略多行數據......
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN webpack-dev-server@2.9.1 requires a peer of webpack@^2.2.0 || ^3.0.0 but none was installed.
npm WARN webpack-dev-middleware@1.12.0 requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but none was installed.
Vue.js 提供一個官方命令行工具,可用於快速搭建大型單頁應用。該工具提供開箱即用的構建工具配置,帶來現代化的前端開發流程。
只需幾分鍾即可創建並啟動一個帶熱重載、保存時靜態檢查以及可用於生產環境的構建配置的項目:
# 全局安裝 vue-cli
$ npm install --global vue-cli
$ vue init webpack my-project
$ vue init webpack test //輸入命令
? Project name (test) test
? Project name test
? Project description (A Vue.js project) 測試項目
? Project description 測試項目
? Author lxx1024
? Author lxx1024
? Vue build standalone
? Install vue-router? (Y/n) Y //安裝路由
? Install vue-router? Yes
? Use ESLint to lint your code? (Y/n) n //Eslint驗證,很嚴謹,所以選擇n
? Use ESLint to lint your code? No
? Setup unit tests with Karma + Mocha? (Y/n) Y
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? (Y/n) Y
? Setup e2e tests with Nightwatch? Yes
vue-cli · Generated "test".
To get started:
cd test
npm install
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
$
cd my-project //進入到項目的根目錄--直接進入到該文件夾即可
$ npm install //安裝依賴包
$ npm run dev //運行項目
下面是運行結果
> npm install > phantomjs-prebuilt@2.1.15 install C:\Users\81487\Desktop\test\node_modules\phantomjs-prebuilt
> node install.js
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
Saving to C:\Users\81487\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip
Receiving...
Error making request.
Error: connect ETIMEDOUT 54.231.81.168:443
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
Please report this full log at https://github.com/Medium/phantomjs
test@1.0.0 C:\Users\81487\Desktop\test
+-- autoprefixer@7.1.5
| +-- browserslist@2.5.1
| | `-- electron-to-chromium@1.3.26
| +-- caniuse-lite@1.0.30000746
| +-- normalize-range@0.1.2
.................
.................
| +-- html-entities@1.2.1
| +-- querystring@0.2.0
| `-- strip-ansi@3.0.1
| `-- ansi-regex@2.1.1
`-- webpack-merge@4.1.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN karma-sinon-chai@1.3.2 requires a peer of sinon@^2.1.0 but none was installed.
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "E:\\nodejs\\node.exe" "E:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! phantomjs-prebuilt@2.1.15 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.15 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the phantomjs-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phantomjs-prebuilt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phantomjs-prebuilt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\81487\Desktop\test\npm-debug.log
> npm run dev > node build/dev-server.js
> Starting dev server...
DONE Compiled successfully in 15700ms23:48:41
> Listening at http://localhost:8080
打開網址顯示vuejs就是成功創建了
精簡版:
1:打開cmd命令行,首先安裝node
步驟:https://nodejs.org/en/download/ node官網,選擇跟自己的電腦匹配的版本進行下載,然后一步步的安裝即可,輸入node -v,如果出現版本信息即表示安裝成功。
2:npm包管理器是集成在node中的,所以直接輸入npm -v就能查看到版本信息
3:輸入npm install -g cnpm --registry=http://registry.npm.taobao.org ,安裝淘寶鏡像安裝相關依賴
4:安裝vue-cli腳手架構建工具,輸入命令 npm install -g vue-cli,安裝完成即可。
5:選定路徑,新建vue項目,這里我是新建到桌面上

6:在上一步得目錄下新建項目,指令vue init webpack +項目名稱

7:上一步之后就會開始新建項目,詢問項目的相關配置。一路yes省事兒沒啥問題
8:進入到項目的文件夾下

9:運行項目,指令npm run dev

10:在瀏覽器中打開這個網址,就能看到

至此,vue項目新建完畢