npm,yarn使用以及更换国内镜像源

原淘宝 npm 域名即将停止解析!!使用老域名的请尽快更新到新域名!

《淘宝 NPM 镜像站喊你切换新域名啦》 https://npm.taobao.org 和 https://registry.npm.taobao.org 将在 2022.06.30 号正式下线和停止 DNS 解析。

域名切换规则:

https://npm.taobao.org => https://npmmirror.com
https://registry.npm.taobao.org => https://registry.npmmirror.com


以下为正文

常用命令:
功能/工具名称yarnnpm
安装全部依赖yarn / yarn installnpm install
添加一个/多个依赖yarn add xxnpm install xx
删除一个/多个依赖yarn removenpm uninstall
搜索 package 包/npm search
yarn:

Yarn 是由 Facebook、Google、Exponent 和 Tilde 联合推出了一个新的 JS 包管理工具 。

安装:

npm install -g yarn

执行 yarn xxx 命令报以下错误时:
在这里插入图片描述
操作以下步骤进行策略更改:

  1. 使用管理员身份运行 cmd 或 Power shell
  2. 输入:set-executionpolicy remotesigned
  3. 输入”Y“,回车保存
yarn 配置源:
// 查询源
yarn config get registry

// 更换国内源
yarn config set registry https://registry.npmmirror.com

// 恢复官方源
yarn config set registry https://registry.yarnpkg.com

// 删除注册表
yarn config delete registry
npm 配置源:

注意 npm 更换国内镜像源之后,将无法再使用 npm search 命令,需要恢复为官方源才可以使用,如果恢复官方源后还不可使用,运行删除注册表命令后重试即可。

// 查询源
npm config get registry

// 更换国内源
npm config set registry https://registry.npmmirror.com

// 恢复官方源
npm config set registry https://registry.npmjs.org

// 删除注册表
npm config delete registry

如果对你有帮助,来一个点赞和收藏吧 。◕‿◕。

  • 8
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

超喜欢你呦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值