Windows 11
WSL 2 terminal
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": "yarn@3.6.1",
"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": "yarn@3.6.1",
"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/backend@1.0.0
import
import
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.
The issue seems to be with yarn wsl 2 adaptation.
I am not sure if the same happens on Ubuntu, but apparently yarn doesn't create the folders when running on wsl (not sure if it is intentional).
Once you run yarn install
on wsl the local node_module folders will remain empty even after re-running the command on powershell unless you delete the yarn.lock and node_modules.
After cloning and testing on MacOS there were no such issues.
I guess deleting the yarn.lock and re-running yarn install
on powershell instead of wsl could be counted as a solution, but it doesn't sound right...
Also keep in mind that even if the folder is empty you will still be able to deploy the server locally (how??) yarn run dev
seemed to be working even with the red underlines on all the imports due to the empty node_module package folder