yarn
yarn copied to clipboard
How do you exclude an entire package and it's dependencies from being hoisted
I'm on version 1.22.X
I have a workspace like this:
/application
/common-package
/project-a
/project-b
Project A and B has similar dependencies but on different versions, this causes a bunch of issues so I want to add Project-B to the workspace but I don't want Project B to hoist ANY dependency in the Application workspace.
I just want Project B to be able to import things from Common-Package.
I have tried:
/application/package.json:
"nohoist": [
"**/application/project-b",
"**/application/project-b/**",
]
But this isn't working and still sends SOME dependencies to application/node_modeles.
I've also tried: /application/project-b/package.json: "nohoist": ["**"]
But again some packages still get hoisted. Then VSCode complains it cannot find them
Same issue for me as well
Hey, I had the same problem. I don't know if this issue is still relevant to you, but I'll drop the solution here. Turns out you have to use the package's name (with scope if you're using one) and not the file system path in nohoist
.
To use your example:
/application
/project-b <- name in package.json is @some-scope/project-b
Then your nohoist
declaration should look like
"nohoist": [
"@some-scope/project-b",
"@some-scope/project-b/**"
]