其他npm命令
[TOC]
安装
- 精确安装最新版本
shell
npm install --save-exact 包名
npm install -E 包名- 安装指定版本
shell
npm install 包名@版本号查询
- 查询包安装路径
shell
npm root [-g]- 查看包信息
shell
npm view 包名 [子信息]
## view aliases:v info show- 查询安装包
shell
npm list [-g] [--depth=依赖深度(0,1,2...)]
## list aliases: ls la ll更新
- 检查有哪些包需要更新
shell
npm outdated- 更新包
shell
npm update [-g] [包名]
## update 别名(aliases):up、upgrade卸载包
shell
npm uninstall [-g] 包名
## uninstall aliases: remove, rm, r, un, unlinknpm 配置
npm的配置会对其他命令产生或多或少的影响
安装好npm之后,最终会产生两个配置文件,一个是用户配置,一个是系统配置,当两个文件的配置项有冲突的时候,用户配置会覆盖系统配置
通常,我们不关心具体的配置文件,而只关心最终生效的配置
通过下面的命令可以查询目前生效的各种配置
shell
npm config ls [-l] [--json]另外,可以通过下面的命令操作配置
- 获取某个配置项
shell
npm config get 配置项- 设置某个配置项
shell
npm config set 配置项=值- 移除某个配置项
shell
npm config delete 配置项