1, before using the first class to master three things, understand that they are used to doing:
npm: Package Manager under nodejs.
webpack: It is the main purpose of all through grammar CommonJS browser need to publish static resources to prepare accordingly, such consolidation and packaging resources.
vue-cli: user-generated Vue project template. (Vue help you quickly start a project, that is, to give you a vue structure, comprising a base dependent libraries, only npm install to install.
2, nodejs download URL: https://nodejs.org/en/ [if too slow to download, can be downloaded on other sites, others have an existing, relatively fast download]
3. Once you have downloaded, double-click the installation:
4, by default, the next step:
5, accept the agreement:
6, select the installation path:
7, it will default to add their own environment variable:
8, goes all the way "next", and finally click finish
9, installed, corresponding role of each file:
10, cmd open the terminal:
11, check whether it is normal
12, and then look at the other two directories, npm local warehouse run in the user directory of the system disk c drive (not seen npm-cache is not used because,
Use a cache directory will generate), we tried to get the two moved back to the directory D: \ nodejs
First established in the following figure two directories:
13, and then run the following two commands
npm config set prefix "D:\nodejs\node_global"
npm config set cache "D:\nodejs\node_cache"
As shown above, let's look at npm local repository, enter the command npm list -global
14, a mirror disposed station, in order to enhance the speed,
Input command npm config set registry = http: //registry.npm.taobao.org arranged mirror sites
Enter the command npm config list displays all configuration information, we focus on a configuration file
C:\Users\Administrator\.npmrc
使用文本编辑器编辑它,可以看到刚才的配置信息
检查一下镜像站行不行命令1
npm config get registry
检查一下镜像站行不行命令2
Npm info vue 看看能否获得vue的信息
注意,此时,默认的模块D:\nodejs\node_modules 目录
将会改变为D:\nodejs\node_global\node_modules 目录,
如果直接运行npm install等命令会报错的。
我们需要做1件事情:
1、增加环境变量NODE_PATH 内容是:D:\nodejs\node_global\node_modules
(注意,一下操作需要重新打开CMD让上面的环境变量生效)
一、测试NPM安装vue.js
命令:npm install vue -g
这里的-g是指安装到global全局目录去
二、测试NPM安装vue-router
命令:npm install vue-router -g
运行npm install vue-cli -g安装vue脚手架
编辑环境编辑path
对path环境变量添加D:\nodejs\node_global
win10以下版本的,横向显示PATH的,注意添加到最后时,不要有分号【;】
重新打开CMD,并且测试vue是否使用正常
注意,vue-cli工具是内置了模板包括 webpack 和 webpack-simple,前者是比较复杂专业的项目,
他的配置并不全放在根目录下的 webpack.config.js 中
初始化,安装依赖
运行npm install安装依赖
成功界面,提示打开地址http://localhost:8080
自动打开浏览器http://localhost:8080/#/
npm run build
生成静态文件,打开dist文件夹下新生成的index.html文件
nmp下新建出来的vue01的目录描述:
大部分借鉴的下面这个大神的:
https://www.cnblogs.com/liluxiang/p/9592003.html
按着大神的步骤操作了一遍,没什么大问题。在此表示感谢,同时声明下,该篇文章只用来自己学习用。