1、安装好webpack、vue及vue-cli脚手架工具(具体可看上一篇);
2、到工程目录下,打开cmd,vue init webpack myVue1,其中,myVue1是建的工程文件夹的名称(你想叫啥子就叫啥子),webpack代表这个工程是在webpack的基础下构建的;
3、之后会出现在需要你填入的项目名称、描述、代码审查、单元测试等;
4、进入文件目录 cd myVue1
5、根据上面的package.json安装npm包文件,npm install
!!注意啦,就在npm install出现了问题,报错如下
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\think\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.9.5
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! chromedriver@2.28.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chromedriver@2.28.0 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 chromedriver 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 chromedriver
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls chromedriver
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! F:\kjStudy\vue\vueJs\firstVue\npm-debug.log
这又让我奔溃鸟,我又回到管理员身份运行全局安装npm install -g chromedriver,装是装好了,但是回到项目里面又来一遍npm install,还是报一样的错误,实属无奈,又使劲百度。。百度到:
”经分析发现,某些版本下,chromedriver 的 zip 文件 url 的响应是 302 跳转,而在 install.js 里使用的是 Node.js 内置的 http 对象的 get 方法无法处理 302 跳转的情况;而在另外一些情况下,则是因为 googleapis.com 被墙了,此时即使采用科学上网的方法也仍然无法获取文件。”看不是很看得懂,但是解决方法倒是写得很清楚,使用:
npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
果然,终于没有再报错了,再使用npm install,,完成安装。
6、使用npm run dev,,ok~~终于跑起来了http://localhost:8080/#/