Forked from https://github.com/timhall/yarn-workspaces to fix this issue.
yarn-workspaces-list
List all available workspaces using the format from yarn workspaces list --verbose --json
from yarn v2.
const { listWorkspaces } = require('yarn-workspaces-list');
const list = await listWorkspaces();
$ workspaces-list
{"location":".","name":"@workspace/monorepo","workspaceDependencies":[],"mismatchedWorkspaceDependencies":[]}
{"location":"packages/a","name":"@workspace/a",...}
{"location":"packages/b","name":"@workspace/b","workspaceDependencies":["packages/a"],...}
API
listWorkspaces([options])
Options:
[cwd]