[{"data":1,"prerenderedAt":221},["ShallowReactive",2],{"\u002F2026\u002Fnodejs-change-registry-mirror":3,"surround-\u002F2026\u002Fnodejs-change-registry-mirror":210},{"id":4,"title":5,"body":6,"categories":184,"date":186,"description":187,"draft":188,"extension":189,"image":190,"meta":191,"navigation":193,"path":194,"permalink":195,"published":195,"readingTime":196,"recommend":195,"references":195,"seo":201,"sitemap":202,"stem":203,"tags":204,"type":208,"updated":186,"__hash__":209},"content\u002Fposts\u002F2026\u002Fnodejs-change-registry-mirror.md","【Node.js】更换镜像源",{"type":7,"value":8,"toc":176},"minimark",[9,13,27,58,65,68,78,81,86,109,115,119,126,129,133,141,146,149,153,164,167,172],[10,11,12],"h2",{"id":12},"镜像源",[14,15,16,17,21,22,26],"p",{},"当 ",[18,19,20],"strong",{},"Node.js"," 的包管理器进行资源包下载时候需要向一个仓库地址进行请求，默认为 ",[23,24,25],"code",{"code":25},"https:\u002F\u002Fregistry.npmjs.org"," 。我们称这个地址为官方镜像源。",[14,28,29,30,33,34,37,38,41,42,45,46,49,50,53,54,57],{},"因为这个镜像源的服务器在",[18,31,32],{},"境外","，因此会因为",[18,35,36],{},"网络波动","造成内容无法正确下载，此时我们需要",[18,39,40],{},"更换","镜像源。国内一些头部",[18,43,44],{},"云服务提供商","（阿里云、腾讯云等）会定期从",[18,47,48],{},"官方服务器","进行数据同步到自己的服务器，因此我们选择这些厂商的镜像源能起到",[18,51,52],{},"加速","和",[18,55,56],{},"稳定","下载的作用。",[14,59,60,61,64],{},"常见的镜像源有很多，这里我们选择更换为",[18,62,63],{},"阿里云","镜像源。",[10,66,67],{"id":67},"更换镜像源",[14,69,70,71],{},"阿里云npm镜像源官网地址为 ",[72,73,77],"a",{"href":74,"rel":75},"https:\u002F\u002Fdeveloper.aliyun.com\u002Fmirror\u002FNPM",[76],"nofollow","阿里云NPM镜像源",[79,80],"copy",{"code":74},[82,83],"pic",{"caption":84,"src":85},"阿里云NPM镜像源官网","https:\u002F\u002Fpostpic.iicemeta.com\u002Fnodejs-change-registry-mirror\u002Fimage.png",[14,87,88,89,92,93,96,97,101,102,105,106],{},"接下来 ",[18,90,91],{},"右键"," 点击 ",[18,94,95],{},"Windows 徽标"," 或按 ",[98,99],"key",{"code":100},"Win"," + ",[98,103],{"code":104},"X"," 打开菜单，然后启动 ",[18,107,108],{},"Windows Powershell",[14,110,111,112],{},"在最新版Windows中，这里也叫做 ",[18,113,114],{},"终端",[82,116],{"caption":117,"src":118},"Windows界面截图","https:\u002F\u002Fpostpic.iicemeta.com\u002Fnodejs-change-registry-mirror\u002Fimage-1.png",[14,120,121,122,125],{},"接下来在弹出的命令窗口中输入以下命令然后按 ",[98,123],{"code":124},"Enter"," 键执行",[79,127],{"code":128},"npm config set registry \"http:\u002F\u002Fregistry.npmmirror.com\"",[82,130],{"caption":131,"src":132},"Powershell命令窗口","https:\u002F\u002Fpostpic.iicemeta.com\u002Fnodejs-change-registry-mirror\u002Fimage-2.png",[134,135,138],"alert",{"title":136,"type":137},"提示","info",[14,139,140],{},"这里可能不会有任何提示，应该就是执行成功了，接下来我们验证一下生效。",[14,142,143,144,125],{},"继续在命令窗口中输入以下命令然后按 ",[98,145],{"code":124},[79,147],{"code":148},"npm config get registry",[82,150],{"caption":151,"src":152},"Powershell命令窗口-验证","https:\u002F\u002Fpostpic.iicemeta.com\u002Fnodejs-change-registry-mirror\u002Fimage-3.png",[134,154,157],{"title":155,"type":156},"成功标志","tip",[14,158,159,160,163],{},"这里返回的内容和我们输入的 ",[23,161,162],{"code":162},"registry.npmmirror.com"," 一样即为设置成功。",[10,165,166],{"id":166},"其他镜像源",[168,169],"link-card",{"link":170,"title":171},"https:\u002F\u002Fmirrors.cloud.tencent.com\u002Fhelp\u002Fnpm.html","腾讯云NPM镜像源说明书",[168,173],{"link":174,"title":175},"https:\u002F\u002Fmirrors.huaweicloud.com\u002FmirrorDetail\u002F5ea0f1e03fdb11a72fd319b2?mirrorName=npm&catalog=language","华为云NPM镜像源说明书",{"title":177,"searchDepth":178,"depth":178,"links":179},"",4,[180,182,183],{"id":12,"depth":181,"text":12},2,{"id":67,"depth":181,"text":67},{"id":166,"depth":181,"text":166},[185],"技术","2026-09-15 10:00:00","在进行前端开发或 Node.js 后端项目时，我们经常需要通过 npm 或其他包管理器来安装依赖。然而，由于网络环境的原因，使用官方的默认源（npm registry）常常会遇到下载速度慢、超时报错（如 ETIMEDOUT）等令人头疼的问题。",false,"md","https:\u002F\u002Fpostpic.iicemeta.com\u002Fnodejs-change-registry-mirror\u002FGemini_Generated_Image_6em6g76em6g76em6.jpg",{"slots":192},{},true,"\u002F2026\u002Fnodejs-change-registry-mirror",null,{"text":197,"minutes":198,"time":199,"words":200},"2 min read",1.72,103200,344,{"title":5,"description":187},{"loc":194},"posts\u002F2026\u002Fnodejs-change-registry-mirror",[20,205,206,207],"教程","AI","基础工具","tech","12_yeCdr9P6EPt4soAxXKh1fo8joNpCAkj5iL4yA8qg",[211,216],{"title":212,"path":213,"stem":214,"date":215,"type":208,"children":-1},"【Node.js】安装教程","\u002F2026\u002Fhow-to-install-nodejs","posts\u002F2026\u002Fhow-to-install-nodejs","2026-09-14 20:22:00",{"title":217,"path":218,"stem":219,"date":220,"type":208,"children":-1},"【Python】安装与换源","\u002F2026\u002Fpython-install-and-pip-source-configuration","posts\u002F2026\u002Fpython-install-and-pip-source-configuration","2026-09-17 18:27:00",1789735338176]