Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to target a single workspace with Yarn?

I have workspaces set up like this

"private": true,
  "workspaces": {
    "packages": [
      "packages/*"
    ],
    "nohoist": [
      "**/firebase-admin",
      "**/firebase-admin/**",
      "**/firebase-functions",
      "**/firebase-functions/**"
    ]
  },

In my packages dir I have a folder common amongst others, with its own package.json etc.

When I execute yarn workspaces run build it triggers the build script for all workspaces. However if I try to target one specific workspace with the yarn workspace command like yarn workspace common build I keep getting the error:

error Unknown workspace "common".

Here's my output from yarn workspaces info:

yarn workspaces v1.17.0
{
  "@gemini/cli": {
    "location": "packages/cli",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@gemini/cloud-functions": {
    "location": "packages/cloud-functions",
    "workspaceDependencies": [
      "@gemini/common"
    ],
    "mismatchedWorkspaceDependencies": []
  },
  "@gemini/common": {
    "location": "packages/common",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@gemini/tools": {
    "location": "packages/tools",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  }
}

I have tried changing the name to package/common or @gemini/common but without luck.

What am I missing here?

like image 915
Thijs Koerselman Avatar asked Jun 28 '19 18:06

Thijs Koerselman


1 Answers

When you want to call command on particular workspace you should use package name which is set in its package.json file "name". In your case it should be:

yarn workspace @gemini/common build

I have tried changing the name to package/common or @gemini/common but without luck.

You should not see error error Unknown workspace "@gemini/common". Maybe some other error you are getting?

like image 104
user123 Avatar answered Oct 12 '22 00:10

user123