全局操作
npm 加参数 -g/--global
yarn 加参数 global
查看已安装 npm 包
1 2 3 4 5 6 7 8
| npm ls/list/la/ll npm ls/list xxx npm list --depth=0 npm list --depth=0 --global/-g
yarn list yarn list xxx yarn global list
|
查看 npm 包版本
1 2 3
| npm view/info/show/v xxx npm view xxx version npm view xxx versions
|
安装npm包
1 2 3 4 5 6
| npm install npm i
yarn add
pnpm i
|
删除npm包
1 2 3
| npm uninstall/remove/rm/r/un/unlink <package>
yarn remove <package>
|
查看可升级的包
1 2
| npm outdated yarn outdated
|
npm 颜色:
黄色表示不符合我们指定的语意化版本范围 - 不需要升级
红色表示符合指定的语意化版本范围 - 需要升级
更新npm包
1 2 3 4 5
| npm install <package>@latest npm update <package>
yarn add <package> yarn upgrade <package> --latest
|
配置镜像
1 2 3 4 5
| npm config set registry https://registry.npm.taobao.org
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
|
查看安装过程
1 2 3
| npm i --timing=true --loglevel=verbose
yarn --verbose
|
npm root
npm link
npm explain
npm why
npm dedupe
代理
1 2 3 4 5 6 7
| yarn config set proxy http://127.0.0.1:15236 yarn config set https-proxy http://127.0.0.1:15236
npm config set https-proxy
yarn config delete proxy yarn config delete https-proxy
|
npm 官方文档
https://docs.npmjs.com/cli/v7/commands