I am working on a project using yarn workspaces. As I have never worked with this feature before I am trying to understand it by following the example setup on the yarn website (using yarn 1.22.19, so classic.yarnpkg.com).
It does the following:
create a package.json with the following content:
{ "private": true, "workspaces": ["workspace-a", "workspace-b"] }
create corresponding subfolders workspace-a and workspace-b
create a package.json for each individual workspace with the contents
{ "name": "workspace-a", "version": "1.0.0", "dependencies": { "cross-env": "5.0.5" } }
and
{
"name": "workspace-b",
"version": "1.0.0",
"dependencies": {
"cross-env": "5.0.5",
"workspace-a": 1.0.0
}
}
it now shows the folder structure how it is supposed to be:
/package.json
/yarn.lock
/node_modules
/node_modules/cross-env
/node_modules/workspace-a -> /workspace-a
/workspace-a/package.json
/workspace-b/package.json
and also that there isn't a package-b folder inside of node_modules.
Well, when following these steps, my structure is very different:
/package.json
/yarn.lock
/node_modules
/node_modules/cross-env
/node_modules/workspace-a -> /workspace-a
/node_modules/workspace-b -> /workspace-b
/workspace-a/node_modules/.bin (containes some scripts referencing the cross-env-package in the root node_modules folder)
/workspace-a/package.json
/workspace-b/node_modules/.bin (containes the same scripts referencing the cross-env-package in the root node_modules folder)
/workspace-b/package.json
Why is it different?
When following another tutorial which adds external and internal dependencies it also behaves different for me, when I install dependencies with e.g. yarn workspace workspace-a add lodash
and yarn workspace workspace-b add [email protected]
(won't work without versioning, which also seems to be a bug) all these dependencies are installed in the root node_modules, which, regarding to the tutorial, also shouldn't be the case.
So my question now is: is something wrong with my local yarn? If not, what else?