My repo
my basic directory structure looks like this:
backend
src
package.json
frontend
apps
admin
src
package.json
user-type-1
src
package.json
core
utils
common
package.json
package.json
yarn.lock
my root package.json looks like this:
{
"private": true,
"name": "root",
"workspaces": {
"packages": [
"backend",
"frontend"
]
},
"engines": {
"node": "^20.5.1"
},
"packageManager": "[email protected]",
"scripts: { ... }
"dependencies": {
"typescript": "^5.1.6",
...
}
...
}
my backend package.json looks like this:
{
"private": true,
"name": "@project/backend",
"version": "1.0.0",
"scripts: { ... }
...
}
my frontend package.json looks like this:
{
"name": "@project/frontend",
"private": true,
"version": "1.0.0",
"workspaces": {
"packages": [
"apps/admin",
"apps/user-type-1",
"core"
]
},
"engines": {
"node": "^20.5.1"
},
"packageManager": "[email protected]",
"scripts: { ... },
"dependencies": {
"@project/backend": "1.0.0",
...
}
...
}
The backend has a bunch of things that the frontend needs, so I want to add the backend ad a dependency for the frontend.
I tried running the following:
yarn workspace @project/frontend add @project/[email protected]
Expected Behavior
- A folder @project/backend is added inside the frontend’s node_modules
- I am able to access backend types and more with
import
- no errors are thrown in the process
Actual Behaviour
- A folder named @project is created inside frontend’s node-modules, but it’s empty
- I cannot access backend types when using
import
- no errors are thrown in the process
Importing the backend from the frontend was previously working, so I am guessing this is not an issue with yarn but with some changes that I made.
However I was unable to find out what caused the yarn to fail, even after returning the package.json
mostly the same as it was before.