70 %

yarn workspace nohoist

When working with electron-forge and yarn workspaces, I ran into an issue where forge was looking for an electron package in the package-local node_modules/electron. This calls for using nohoist, which will put all of the packages we specify into the local node_modules for that package and not hoist them into the root workspace package.json.

We also want every other package to be local for the desktop package we're working on, because the electron-forge webpack integration I'm using also breaks for the same reason. We can nohoist everything that desktop depends on using desktop/**.

json
{
"name": "my-workspace",
"version": "1.0.0",
"main": "index.js",
"private": true,
"author": "christopherbiscardi <chris@christopherbiscardi.com> (@chrisbiscardi)",
"license": "MIT",
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"desktop/**"
]
}
}

The workspace looks like this:

.
├── package.json
├── packages
│ ├── some-package
│ │ └── package.json
│ └── desktop
│ └── package.json
└── yarn.lock