yarn命令及.yarnrc配置文件使用

本文介绍了如何通过设置.yarnrc文件来配置淘宝镜像源,包括registry、sass_binary_site、phantomjs_cdnurl等,以加快Yarn在项目中下载依赖的速度。只需在项目根目录创建.yarnrc文件并添加相应配置,之后使用yarn add命令时,将从淘宝镜像源拉取包,显著提高下载效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

.yarnrc

设置淘宝镜像

yarn config set registry https://registry.npmmirror.com // 设置淘宝镜像

项目根(src同级)目录添加.yarnrc文件

为项目设置镜像源及包的路径

registry "https://registry.npmmirror.com"
sass_binary_site "https://cdn.npmmirror.com/binaries/node-sass"

其中 registry “https://registry.npmmirror.com” 就是指定淘宝镜像源,是最重要的。
其余是指定对应包的下载路径。
添加文件且编辑结束后再使用yarn add命令就是从配置的镜像源中拉取需要的包,速度会更快。

failed to load config from D:\朗慧\digital-welcome-project\vite.config.ts error when starting dev server: Error: You installed esbuild for another platform than the one you're currently using. This won't work because esbuild is written with native code and needs to install a platform-specific binary executable. Specifically the "@esbuild/win32-x64" package is present but this platform needs the "@esbuild/win32-ia32" package instead. People often get into this situation by installing esbuild on Windows or macOS and copying "node_modules" into a Docker image that runs Linux, or by copying "node_modules" between Windows and WSL environments. If you are installing with npm, you can try not copying the "node_modules" directory when you copy the files over, and running "npm ci" or "npm install" on the destination platform after the copy. Or you could consider using yarn instead of npm which has built-in support for installing a package on multiple platforms simultaneously. If you are installing with yarn, you can try listing both this platform and the other platform in your ".yarnrc.yml" file using the "supportedArchitectures" feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures Keep in mind that this means multiple copies of esbuild will be present. Another alternative is to use the "esbuild-wasm" package instead, which works the same way on all platforms. But it comes with a heavy performance cost and can sometimes be 10x slower than the "esbuild" package, so you may also not want to do that.
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值