https://blog.csdn.net/qq_29689343/article/details/130164840
https://blog.csdn.net/weixin_45046532/article/details/139681731
npm | yarn | pnpm | |
---|---|---|---|
初始化 | npm init | yarn init | pnpm init |
安裝依賴 | npm install | yarn install | pnpm install |
安裝依賴簡(jiǎn)寫 | npm i | yarn add | pnpm add |
安裝具體版本 | npm install package@version | yarn add package@version | pnpm add package@version |
安裝并添加到dependencies | npm install --save/-S | yarn add | pnpm add |
安裝并添加到devDep | npm install --save-dev/-D | yarn add --dev/-D | pnpm add --save-dev? |
卸載 | npm uninstall | yarn remove | pnpm remove |
清除緩存 | npm cache clean | yarn cache clean |
npm config get registry // 查看npm當(dāng)前鏡像源
npm config set registry https://registry.npmmirror.com/ // 設(shè)置npm鏡像源為淘寶鏡像
npm cache clean --force //清除緩存
yarn config get registry // 查看yarn當(dāng)前鏡像源
yarn config set registry https://registry.npm.taobao.org/ // 設(shè)置yarn鏡像源為淘寶鏡像
yarn cache clean
pnpm get registry
pnpm config set registry https://registry.npmmirror.com/
常用鏡像源
npm --- https://registry.npmjs.org/ 官方鏡像源
cnpm --- https://r.cnpmjs.org/ 國(guó)內(nèi)鏡像源
taobao --- https://registry.npmmirror.com/ 淘寶鏡像源
nj --- https://registry.nodejitsu.com/
rednpm --- https://registry.mirror.cqupt.edu.cn/
npmMirror --- https://skimdb.npmjs.com/registry/
deunpm --- http://registry.enpmjs.org/
阿里云鏡像:https://npm.aliyun.com/
中國(guó)科技大學(xué)鏡像:https://mirrors.ustc.edu.cn/npm/
華為云鏡像:https://mirrors.huaweicloud.com/repository/npm/
七牛云鏡像:https://npm.qiniu.com/
鏡像源切換 nrm
npm install -g nrm
//驗(yàn)證 nrm 是否安裝成功
nrm --version
//查看所有鏡像源
nrm ls
// 使用淘寶鏡像源
nrm use taobao
//添加新的鏡像源
nrm add <registry-name> <registry-url>
//刪除鏡像源
nrm del <registry-name>
// 切換當(dāng)前使用的鏡像源
nrm use <registry-name>
// 測(cè)試所有鏡像源的速度
nrm test
npm-通過緩存機(jī)制加速了包的安裝和執(zhí)行過程代承,隨著時(shí)間的推移奢驯,緩存文件可能會(huì)積累并導(dǎo)致諸如依賴過時(shí)鳄梅、安裝錯(cuò)誤或意外行為等問題不同。
//清除緩存
npm cache clean --force
//或使用手動(dòng)刪除田炭,通過命令找到緩存對(duì)應(yīng)文件夾
npm config get cache
//驗(yàn)證緩存是否已清理
npm cache clean --force