Yarn install package from npm and not workspace

Viewed 257

I'm encountering a problem with yarn workspaces, here is my situation :

I have a monorepo that contains :

  • a packages folder containing npm packages
  • an apps folder containing nodejs apps

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.

How can I tell yarn to not use the workspace folder for install but download it from the remote? I'm using the workspaces only for local builds.

2 Answers

If you are using yarn berry, it looks up the package in your workspace first and remote registry after. This behavior can be changed by setting enableTransparentWorkspaces: false in your .yarnrc.yml file at root.

// .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.

"my-package": "workspace:^2.0.17",

See more at:

Related