npm 常用命令

  1. npm install moduleNames:安装Node模块

  2. npm install moduleNames –save:安装Node模块并添加依赖(写入到package.json)会在当前目录下安装包,版本信息也会添加到依赖中,会安装到dependencies选项中

  3. npm install moduleNames –save-dev 开发阶段使用的依赖包,会安装到devDependencies选项中

  4. npm install moduleNames -g 全局安装

  1. npm list:查看当前目录下已安装的node包

  2. npm list moduleNames: 查看模块版本

  3. npm update moduleName:更新node模块

  4. npm uninstall moudleName:卸载node模块

  5. npm init: 初始化

  6. npm ls: 查看所有模块

  7. 初始化工程后会生成package.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"name": "npm",
"version": "1.0.0",
"description": "",
"main": "index.js",//入口文件
"dependencies": { //项目依赖包
"_jquery@3.2.1@jquery": "^3.2.1",
"jquery": "^3.2.1"
},
"devDependencies": {},//开发阶段依赖的包
"scripts": { //命令
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}