npmyarnpkgmonorepoyarn-workspacesnpm-workspaces

Yarn workspaces with absolute path


I am using yarn 1.22.19, my package.json file contains

  "workspaces": [
    "/some/path/packages/*"
  ],

When I run yarn install it doesn't create symlink for the packages under that path. I also tried to delete yarn.lock but it didn't help.

The packages I want to link are not under the project's sub-tree.

Is it possible?


Solution

  • The defined workspaces must be descendants of the workspace root.

    source

    Workspaces must be descendants of the workspace root in terms of folder hierarchy. You cannot and must not reference a workspace that is located outside of this filesystem hierarchy.

    So if your workspace root is located somewhere along the path /some/path/packages/*, for example at /some/path, then absolute paths should work. However, with this structure requirement there is no need to use absolute paths and you can define the workspaces as packages/*.