一、使用之前,我们先来掌握3个东西是用来干什么的。
npm: Nodejs下的包管理器。
webpack: 它主要的用途是通过CommonJS的语法把所有浏览器端需要发布的静态资源做相应的准备,比如资源的合并和打包。
vue-cli: 用户生成Vue工程模板。(帮你快速开始一个vue的项目,也就是给你一套vue的结构,包含基础的依赖库,只需要 npm install就可以安装)
开始:
![78961296c98297c7e4db0a5b29ec8c0d.png](https://img-blog.csdnimg.cn/img_convert/78961296c98297c7e4db0a5b29ec8c0d.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
下载好就下一步,下一步,这里就不多介绍了。
下载好,我们就可以看见一下内容。
![dc014e015e9627d42616e0fb434a3226.png](https://img-blog.csdnimg.cn/img_convert/dc014e015e9627d42616e0fb434a3226.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
![54b40b372c916d47f8d886c7a49eeaed.png](https://img-blog.csdnimg.cn/img_convert/54b40b372c916d47f8d886c7a49eeaed.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
![9b69c18a78b612e01a5e73ae8814af79.png](https://img-blog.csdnimg.cn/img_convert/9b69c18a78b612e01a5e73ae8814af79.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
![c9412be1aca75540a6c33620814911c7.png](https://img-blog.csdnimg.cn/img_convert/c9412be1aca75540a6c33620814911c7.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
然后运行以下2条命令
npm config set prefix "D:softwareodejsode_global"
npm config set cache "D:softwareodejsode_cache"
![29e16558bf70319557ad1c3694acfab7.png](https://img-blog.csdnimg.cn/img_convert/29e16558bf70319557ad1c3694acfab7.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
输入命令npm config set registry=http://registry.npm.taobao.org 配置镜像站
![68a9de5b869489b6a6cd827b7b4f46f4.png](https://img-blog.csdnimg.cn/img_convert/68a9de5b869489b6a6cd827b7b4f46f4.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
如果直接运行npm install等命令会报错的。
我们需要做1件事情:
1、增加环境变量NODE_PATH 内容是:D:softwareodejsode_globalode_modules
![f6fe13be99599d170f4c08f5861aeaee.png](https://img-blog.csdnimg.cn/img_convert/f6fe13be99599d170f4c08f5861aeaee.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
![0e310fd3312a8c3d1ef18180b196abc9.png](https://img-blog.csdnimg.cn/img_convert/0e310fd3312a8c3d1ef18180b196abc9.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
(注意,以下操作需要重新打开CMD让上面的环境变量生效)
一、测试NPM安装vue.js
命令:npm install vue -g
这里的-g是指安装到global全局目录去
二、测试NPM安装vue-router
命令:npm install vue-router -g
三、安装vue脚手架
运行npm install vue-cli -g安装vue脚手架
![1519b99a46d85c3b0bbf68f774e5f642.png](https://img-blog.csdnimg.cn/img_convert/1519b99a46d85c3b0bbf68f774e5f642.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
最后在idea中,npm install ,npm run start 就可以启动vue项目了
![d7c88137021dbd38518aea4b15777e86.png](https://img-blog.csdnimg.cn/img_convert/d7c88137021dbd38518aea4b15777e86.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
喜欢点下关注,你的关注是我写作的最大支持
![132a26edaf5b3856a4a9f8db470832e8.png](https://img-blog.csdnimg.cn/img_convert/132a26edaf5b3856a4a9f8db470832e8.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
![f18f0b72eebc0536bffff23d8179918a.png](https://img-blog.csdnimg.cn/img_convert/f18f0b72eebc0536bffff23d8179918a.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)
![7e9b0e610317db1ddc3a0d45099f6070.png](https://img-blog.csdnimg.cn/img_convert/7e9b0e610317db1ddc3a0d45099f6070.png)
![664eb5ed028041336aad2f5e2abd6d60.gif](https://img-blog.csdnimg.cn/img_convert/664eb5ed028041336aad2f5e2abd6d60.gif)