npm 设置镜像

要在npm中设置镜像,你可以使用npm config命令。以下是设置npm镜像的步骤:

  1. 临时使用淘宝镜像:

npm --registry https://registry.npmmirror.com install package-name
  1. 永久设置镜像:

npm config set registry https://registry.npmmirror.com
  1. 通过.npmrc文件设置(全局或项目级别):

    在你的用户目录或项目目录下,创建或编辑.npmrc文件,添加以下内容:

registry=https://registry.npmmirror.com
  1. 使用环境变量设置(只对当前会话有效):

    在命令行中直接设置环境变量:

export npm_config_registry=https://registry.npmmirror.com

以上任选一种方法即可设置npm的镜像源。

使用 npm config list 命令的第一行就可以查看到npmrc文件在哪里

; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\\Users\\123\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v20.12.2
; npm local prefix = C:\Users\11200
; npm version = 10.5.0
; cwd = C:\Users\123
; HOME = C:\Users\123
; Run `npm config ls -l` to show all defaults.

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值