kenpeter
kenpeter

Reputation: 8274

Yarn install a single package to single workspace

This is my project set up

proj:
  package.json - workspaces["app/frontend", "app/backend"]
  app
    frontend - package.json
    backend - package.json

say I cd to proj

I want to do yarn workspace app/frontend add uuid -dev (add a pkg to one of the workspace)

err is Unknown workspace "app/frontend", wonder what is the correct syntax?

Upvotes: 1

Views: 2037

Answers (2)

Anton
Anton

Reputation: 1638

When you define your workspaces in the package.json you should use relative path to the workspace:

"workspaces": [
  "app/frontent",
  "app/backend"
]

However, when you refer to your workspace in yarn workspace ... command you should use the package name of this workspace (including namespace).

For example, if your frontend/package.json defines

{
  name: "@myproj/frontend".
  ...
}

you will use

yarn workspace @myproj/frontent add uuid --save-dev

Upvotes: 1

kenpeter
kenpeter

Reputation: 8274

yarn workspace frontend add uuid --save-dev

Upvotes: 1

Related Questions