[英]Yarn install package from npm and not workspace
I'm encountering a problem with yarn workspaces, here is my situation:我遇到了纱线工作区的问题,这是我的情况:
I have a monorepo that contains:我有一个包含:
In one of my apps, I'm trying to install a package from my packages folder that is published in npm, but when I do yarn install
, it keeps using the workspace folder and doesn't download the npm package nor updates the yarn lock.在我的一个应用程序中,我试图从 npm 中发布的包文件夹中安装 package,但是当我执行yarn install
时,它会继续使用工作区文件夹并且不会下载 npm package 也不会更新 yarn 锁.
How can I tell yarn to not use the workspace folder for install but download it from the remote?我怎样才能告诉 yarn 不要使用工作区文件夹进行安装,而是从远程下载它? I'm using the workspaces only for local builds.我仅将工作区用于本地构建。
If you are using yarn berry, it looks up the package in your workspace first and remote registry after.如果您使用的是 yarn berry,它会先在您的工作区中查找 package,然后再查找远程注册表。 This behavior can be changed by setting enableTransparentWorkspaces: false
in your .yarnrc.yml
file at root.可以通过在根目录下的.yarnrc.yml
文件中设置enableTransparentWorkspaces: false
来更改此行为。
// .yarnrc.yml
enableTransparentWorkspaces: false
...
If you want to get a package from your workspace with the above option is set, you should explicitly add workspace:
protocol as a prefix for your package name in your package.json
.如果您想从设置了上述选项的工作区中获取 package,您应该在 package.json 中明确添加workspace:
protocol 作为package.json
名称的前缀。
"my-package": "workspace:^2.0.17",
See more at:更多信息请访问:
if it is yarn 2+ (berry) you can use npm protocol如果是纱线 2+(浆果),您可以使用npm 协议
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.