WINDOWS VUE 环境安装
1. 下载NODE: https://nodejs.org/en/ 左侧是稳定版, 右侧是最新版。
2. 安装完成后用如下命令进行检测:
node -v
npm -v
3. 设置环境变量,如果你的系统经常不是管理员登录 , 建议设置到非C盘:
cd D:\Program Files\ d: mkdir nodejs cd nodejs mkdir node_global mkdir node_cache npm config set prefix "D:\Program Files\nodejs\node_global" npm config set cache "D:\Program Files\nodejs\node_cache"
在系统环境变量中添加如下变量:
NODE_PATH D:\Program Files\nodejs\node_global\node_modules
4. 测试安装一个模块:
npm install express -g
node
>require('express')
如无报错, 则环境变量等设置无误。
5. 安装VNPM:
npm install -g cnpm --registry=https://registry.npm.taobao.org
设置环境变量:
PATH D:\Program Files\nodejs\node_global
cnpm -v cnpm@5.3.0 (D:\Program Files\nodejs\node_global\node_modules\cnpm\lib\parse_argv.js) npm@5.10.0 (D:\Program Files\nodejs\node_global\node_modules\cnpm\node_modules\npm\lib\npm.js) node@8.11.2 (C:\Program Files\nodejs\node.exe) npminstall@3.6.0 (D:\Program Files\nodejs\node_global\node_modules\cnpm\node_modules\npminstall\lib\index.js) prefix=D:\Program Files\nodejs\node_global win32 x64 6.1.7601 registry=https://registry.npm.taobao.org
6. 安装VUE:
cnpm install vue √ Installed 1 packages √ Linked 0 latest versions √ Run 0 scripts √ All packages installed (1 packages installed from npm registry, used 955ms, speed 720.12kB/s, json 1(22.75kB), tarball 664.97kB) cnpm install --global vue-cli Downloading vue-cli to D:\Program Files\nodejs\node_global\node_modules\vue-cli_tmp Copying D:\Program Files\nodejs\node_global\node_modules\vue-cli_tmp\_vue-cli@2.9.3@vue-cli to D:\Program Files\nodejs\node_global\node_modules\vue-cli Installing vue-cli's dependencies to D:\Program Files\nodejs\node_global\node_modules\vue-cli/node_modules [1/20] commander@^2.9.0 installed at node_modules\_commander@2.15.1@commander [2/20] multimatch@^2.1.0 installed at node_modules\_multimatch@2.1.0@multimatch [3/20] ora@^1.3.0 installed at node_modules\_ora@1.4.0@ora [4/20] chalk@^2.1.0 installed at node_modules\_chalk@2.4.1@chalk [5/20] rimraf@^2.5.0 existed at node_modules\_rimraf@2.6.2@rimraf [6/20] minimatch@^3.0.0 installed at node_modules\_minimatch@3.0.4@minimatch [7/20] semver@^5.1.0 installed at node_modules\_semver@5.5.0@semver [8/20] consolidate@^0.14.0 installed at node_modules\_consolidate@0.14.5@consolidate [9/20] tildify@^1.2.0 installed at node_modules\_tildify@1.2.0@tildify [10/20] uid@0.0.2 installed at node_modules\_uid@0.0.2@uid [11/20] read-metadata@^1.0.0 installed at node_modules\_read-metadata@1.0.0@read-metadata [12/20] coffee-script@1.12.7 existed at node_modules\_coffee-script@1.12.7@coffee-script [13/20] user-home@^2.0.0 installed at node_modules\_user-home@2.0.0@user-home [14/20] validate-npm-package-name@^3.0.0 installed at node_modules\_validate-npm-package-name@3.0.0@validate-npm-package-name [15/20] metalsmith@^2.1.0 installed at node_modules\_metalsmith@2.3.0@metalsmith [16/20] async@^2.4.0 installed at node_modules\_async@2.6.0@async [17/20] inquirer@^3.3.0 installed at node_modules\_inquirer@3.3.0@inquirer [18/20] request@^2.67.0 installed at node_modules\_request@2.86.0@request [19/20] download-git-repo@^1.0.1 installed at node_modules\_download-git-repo@1.0.2@download-git-repo [20/20] handlebars@^4.0.5 installed at node_modules\_handlebars@4.0.11@handlebars deprecate metalsmith@2.3.0 › gray-matter@2.1.1 › coffee-script@^1.12.4 CoffeeScript on NPM has moved to "coffeescript" (no hyphen) Recently updated (since 2018-05-13): 2 packages (detail see file D:\Program Files\nodejs\node_global\node_modules\vue-cli\node_modules\.recently_updates.txt) 2018-05-15 → request@^2.67.0(2.86.0) (20:06:18) → download-git-repo@1.0.2 › download@5.0.3 › decompress@4.2.0 › decompress-tar@4.1.1 › tar-stream@^1.5.2(1.6.1) (05:19:03) All packages installed (257 packages installed from npm registry, used 8s, speed 811.92kB/s, json 240(1.61MB), tarball 4.47MB) [vue-cli@2.9.3] link D:\Program Files\nodejs\node_global\vue@ -> D:\Program Files\nodejs\node_global\node_modules\vue-cli\bin\vue [vue-cli@2.9.3] link D:\Program Files\nodejs\node_global\vue-init@ -> D:\Program Files\nodejs\node_global\node_modules\vue-cli\bin\vue-init [vue-cli@2.9.3] link D:\Program Files\nodejs\node_global\vue-list@ -> D:\Program Files\nodejs\node_global\node_modules\vue-cli\bin\vue-list
创建一个基于 webpack 模板的新项目:
e:\vue_study>vue init webpack my_first_vue ? Target directory exists. Continue? Yes 'git' �����ڲ����ⲿ���Ҳ���ǿ����еij��� �������ļ� ? Project name my_first_vue ? Project description A Vue.js project ? Author ? Vue build standalone ? Install vue-router? Yes ? Use ESLint to lint your code? Yes ? Pick an ESLint preset Standard ? Set up unit tests Yes ? Pick a test runner jest ? Setup e2e tests with Nightwatch? Yes ? Should we run `npm install` for you after the project has been created? (recommended) no vue-cli · Generated "my_first_vue". # Project initialization finished! # ======================== To get started: cd my_first_vue npm install (or if using yarn: yarn) npm run lint -- --fix (or for yarn: yarn run lint --fix) npm run dev Documentation can be found at https://vuejs-templates.github.io/webpack
进入项目目录,执行所需模块安装:
e:\vue_study\my_first_vue>cnpm install / [46/58] Installing vue-template-es2015-compiler@^1.6.0platform unsupported babel-loader@7.1.4 › webpack@3.12.0 › watchpack@1.6.0 › chokidar@2.0.3 › fsevents@^1.1.2 Package require os(darwin) not com patible with your platform(win32) [fsevents@^1.1.2] optional install error: Package require os(darwin) not compatible with your platform(win32) √ Installed 58 packages √ Linked 987 latest versions Downloading https://cdn.npm.taobao.org/dist/chromedriver/2.38/chromedriver_win32.zip Saving to C:\Users\REBIRT~1.HUA\AppData\Local\Temp\chromedriver\chromedriver_win32.zip Received 782K... Received 1564K... Received 2346K... Received 3127K... Received 3299K total. Extracting zip contents Copying to target path e:\vue_study\my_first_vue\node_modules\_chromedriver@2.38.3@chromedriver\lib\chromedriver Done. ChromeDriver binary available at e:\vue_study\my_first_vue\node_modules\_chromedriver@2.38.3@chromedriver\lib\chromedriver\chromedriver.exe √ Run 2 scripts peerDependencies link ajv@5.5.2 in e:\vue_study\my_first_vue\node_modules\_ajv-keywords@2.1.1@ajv-keywords unmet with e:\vue_study\my_first_vue\node_modules\ajv(6.5.0) deprecate nightwatch@0.9.21 › proxy-agent@2.0.0 › socks-proxy-agent@2.1.1 › socks@~1.1.5 If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an impor t issue introduced in 2.1.0 Recently updated (since 2018-05-13): 29 packages (detail see file e:\vue_study\my_first_vue\node_modules\.recently_updates.txt) Today: → webpack-dev-server@2.11.2 › http-proxy-middleware@0.17.4 › http-proxy@1.17.0 › follow-redirects@^1.0.0(1.5.0) (00:17:27) √ All packages installed (1196 packages installed from npm registry, used 4m, speed 221.45kB/s, json 1045(8.19MB), tarball 42.24MB)
运行环境:
e:\vue_study\my_first_vue>cnpm run dev > my_first_vue@1.0.0 dev e:\vue_study\my_first_vue > webpack-dev-server --inline --progress --config build/webpack.dev.conf.js 95% emitting DONE Compiled successfully in 5142ms I Your application is running here: http://localhost:8080
尝试访问: