简体   繁体   English

如何在不更新 yarn.lock 的情况下对工作区中的包进行符号链接?

[英]How to symlink a package in workspace without updating yarn.lock?

package.json -包.json -

"workspaces": [
  "packages/*",
  "samples/*"
],
"packageManager": "yarn@3.1.0"

I want to install and symlink the dependencies in samples but I don't want the yarn install to update the yarn.lock file.我想在示例中安装和符号链接依赖项,但我不希望 yarn install 更新 yarn.lock 文件。 Is there a setting in workspaces or yarn to achieve this?工作区或纱线中是否有设置来实现这一点?

I think you want to use yarn add your-package@"workspace:^" (or other workspace: ranges ).我认为您想使用yarn add your-package@"workspace:^" (或其他workspace: 范围)。 This does end up in your yarn.lock , but when publishing your package yarn will actually replace the dependency with a versioned dependency (depending on the range specifier).这最终会出现在您的yarn.lock中,但是在发布包时,yarn 实际上会用版本化的依赖项替换依赖项(取决于范围说明符)。 Also, it doesn't include any hash or anything in the yarn.lock, so you don't need to reinstall when changes are made to the package.此外,它在 yarn.lock 中不包含任何散列或任何内容,因此在对包进行更改时无需重新安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM