'How can I fix the yarn error 'Unknown workspace'?
Problem
Running yarn workspace <nohoisted-package> start gives error Unknown workspace "twitter-digester-frontend".
Details
Root package.json
{
"name": "x",
"private": true,
"version": "1.0.0",
"workspaces": {
"packages": ["x-backend"],
"nohoist": ["x-frontend"]
},
"scripts": {
"backend": "yarn workspace x-backend",
"frontend": "yarn workspace x-frontend"
}
}
Command
yarn workspace x-frontend startfails with the error above...Unknown workspace....yarn workspace x-backend startworks, though (i.e., works for non-nohoisted packages).
Question
Why does yarn workspace fail with nohoisted packages?
I don't fully understand nohoist. I'm mainly using it because Angular CLI in x-frontend couldn't read node_modules when not using nohoist. I'm assuming it only means don't symlink packages - that's why I see no reason yarn workspace <nohoisted-package> <script> shouldn't work.
Solution 1:[1]
The first thing your root package.json should contain an array of your workspaces:
{
...
"workspaces": [
"example",
"my-pkg-js"
]
}
The second thing to check is when you run yarn workspace <workspace> start the <workspace> stands for the name in your package.json in your package directory. For example:
yarn workspace package-name start
The name property in my-pkg-js/package.json file should be something like:
{
...
"name": "package-name"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mikemaccana |
