npm
一.Vue框架引入的两种方式
1.网上下载vue.js文件,在将vue.js文件拷贝到项目中,这是传统的方式
2.Npm的方式.
二.Npm
1.Npm是什么?
npm是前端js框架中的maven,他用来远程下载js类库,和maven’的作用很像.
maven的依赖文件是pom文件,npm的文件是package.json,用来描述当前项目的.
2.npm的安装
(1)下载node.js,node.js中自带了npm.
(2)Cmd中验证是否安装了node.js 和 npm
C:\Users\13570>node -v
v12.16.1
C:\Users\13570>npm -v
6.13.4
C:\Users\13570>
3.npm初始化项目
(1)新建一个文件夹,在文件夹中进入cmd,输入 npm -init
D:\node.js\project\study\npm-demo3>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (npm-demo3)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author: gl
license: (ISC)
About to write to D:\node.js\project\study\npm-demo3\package.json:
{
"name": "npm-demo3", //这是项目名称
"version": "1.0.0", //版本号
"description": "", //描述
"main": "index.js", //入口文件
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "gl", //作者
"license": "ISC" //证书
}
Is this OK? (yes) y
D:\node.