Yarn Workspaces: How and where should I install my dependencies?

Viewed 683

So, I know the tile isn't saying much, but I have the following issue. I am working on a project which uses yarn workspaces. I have 2 workspaces so far. One thing that confuses me is: should common dependencies stay in the root project (the one where workspaces is described)? I currently have some common(by common I mean they are used in both workspaces) dependencies in the root project and some(non common) in the workspace package.json.

I also have one more issue I need help with, but I feel it is connected with the previous one. Whenever I go to a workspace folder and I do yarn add <dep name> Some of my dependencies disappear. I have to go back to the root, delete yarn.lock and run yarn. Now all dependencies are installed and in the right place.

I feel like I am missing something. I have researched a lot, but wasn't able to find a good "best practices" example/article. I hope that some of you have been able to achieve the "right formula" and are going to be able to help me.

0 Answers
Related