[Bug?]: `yarn bin` reports wrong bin from `installConfig.hoistingLimits` workspace (`nodeLinker: node-modules`)
See original GitHub issueSelf-service
- I’d be willing to implement a fix
Describe the bug
I have a few workspaces, they’re depending on @graphql-codegen/cli
which contributes a graphql-codegen
bin script.
One of the workspaces zapier
has installConfig.hoistingLimits
set to workspaces
, the other workspaces don’t have this set.
When I run yarn bin graphql-codegen
in one of the other workspaces it gives a path under the zapier
workspace.
Instead I would expect it to give the path not from that workspace.
The problem this causes is that different copies of other packages end up getting imported within the same node process (e.g. graphql
is particularly fragile for this).
To reproduce
const fs = require('fs').promises;
await fs.writeFile('.yarnrc.yml', 'nodeLinker: node-modules');
await packageJsonAndInstall({
"name": "root",
"workspaces": [
"packages/*"
],
"dependencies": {
"rimraf": "^2.0.0"
},
});
await fs.mkdir('packages/nohoist', { recursive: true });
await fs.writeFile("packages/nohoist/package.json", `{
"dependencies": {
"rimraf": "^2.0.0"
},
"name": "nohoist",
"installConfig": {
"hoistingLimits": "workspaces"
}
}`);
await yarn(`install`);
const rootRimrafPath = await yarn(`bin`, `rimraf`)
const nohoistRimrafPath = await yarn(`workspace`, `nohoist`, `bin`, `rimraf`);
expect(rootRimrafPath).not.toEqual(nohoistRimrafPath);
Environment
System:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Max
Binaries:
Node: 16.14.0 - /private/var/folders/jq/3x3ddtjx3rb9nwy79zxfwnj00000gn/T/xfs-6ab2aa01/node
Yarn: 3.2.4 - /private/var/folders/jq/3x3ddtjx3rb9nwy79zxfwnj00000gn/T/xfs-6ab2aa01/yarn
npm: 8.3.1 - ~/.n/bin/npm
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
React Native monorepo support and yarn 3.1+ · Issue #3699 ...
Describe the bug. Yarn 3.1.0 now hoists dependencies of dependencies when using installConfig.hoistingLimits: "workspaces" .
Read more >Configuration options | Yarn - Package Manager
List of all the configuration option for Yarn (yarnrc files) ... If false, Yarn won't link workspaces just because their versions happen to...
Read more >migrating to yarn 3 + workspaces + nohoist - Stack Overflow
I've realized that installConfig is a section of package.json . Each workspace can define this section to override the default behaviour: <repo- ...
Read more >Advanced package manager features for npm, Yarn, and pnpm
.npmrc node-linker=pnp symlink=false. After running pnpm i , the project structure looks like this. . ├── node_modules/ │ ├── .bin/ ...
Read more >JS Monorepo Blog Part 2 - Carbon Health
We noticed that Yarn is not able to properly install dependencies when switching installConfig settings. Some of the settings were things like ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@larixer sure thing, I’ve added a Sherlock reproduction.
@bradleyayers Great, thank you very much!