npm yarn pnpm

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
安装依赖简写 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

pnpm文档

npm config get registry  // 查看npm当前镜像源
npm config set registry https://registry.npmmirror.com/  // 设置npm镜像源为淘宝镜像
npm cache clean --force //清除缓存

yarn config get registry  // 查看yarn当前镜像源
yarn config set registry https://registry.npm.taobao.org/  // 设置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/ 国内镜像源
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/
中国科技大学镜像:https://mirrors.ustc.edu.cn/npm/
华为云镜像:https://mirrors.huaweicloud.com/repository/npm/
七牛云镜像:https://npm.qiniu.com/

镜像源切换 nrm

npm install -g nrm
//验证 nrm 是否安装成功
 nrm --version
//查看所有镜像源
 nrm ls
// 使用淘宝镜像源
nrm use taobao
//添加新的镜像源
nrm add <registry-name> <registry-url>
//删除镜像源
nrm del <registry-name>
// 切换当前使用的镜像源
nrm use <registry-name>
// 测试所有镜像源的速度
nrm test

npm-通过缓存机制加速了包的安装和执行过程,随着时间的推移,缓存文件可能会积累并导致诸如依赖过时、安装错误或意外行为等问题。

//清除缓存
npm cache clean --force 
//或使用手动删除,通过命令找到缓存对应文件夹
npm config get cache
//验证缓存是否已清理
npm cache clean --force 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容