npm-- installation tutorial, install scaffolding vue

npm: is accompanied NodeJS package management tools installed together, can solve many problems on NodeJS code for deployment. For example, commonly used are:

  1) allows users to download from the server written by someone else NPM third-party packages to local use.

  2) allows users to download and install the command-line program written by someone else to use local NPM from the server.

  3) allows users to write their own bag or command line program NPM uploaded to the server for others to use.

 

First of all: start nodejs.org download nodejs

 

As shown, download 8.9.3LTS (recommended for most users use)

Double-click the installation

 

Next up

 

Can use the default path, the present example is modified self-d: \ nodejs

 

 

Click Install to install

Click Finish

 

See if the directory has the following files

 

Open the control command-line program (CMD), check whether it is normal

 

 

 

 

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, to use a cache directory will generate), we tried to get the two directory moved back to D: \ nodejs

First established in the following figure 2 directory

 

 

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

 

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

 

Use a text editor to edit it, you can just see the configuration information

 

Check the mirror sites, okay Command 1

npm config get registry

 

 

Check the mirror sites, okay Command 2

Npm info vue see if you can get the information vue

 

Notice that the default module D: \ nodejs \ node_modules directory

将会改变为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

三、安装vue脚手架

运行npm install vue-cli -g 

 

 编辑环境、编辑path

 

对path环境变量添加D:\nodejs\node_global

win10以下版本的,横向显示PATH的,注意添加到最后时,不要有分号【;】

 

重新打开CMD,并且测试vue是否使用正常

 

注意,vue-cli工具是内置了模板包括 webpack 和 webpack-simple,前者是比较复杂专业的项目,他的配置并不全放在根目录下的 webpack.config.js 中。

 

 

初始化,安装依赖

 

npm run dev(运行dev)

自动打开浏览器http://localhost:8080/#/

 

npm run build

生成静态文件,打开dist文件夹下新生成的index.html文件

Guess you like

Origin www.cnblogs.com/0daybug/p/11793944.html