question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug?]: `yarn bin` reports wrong bin from `installConfig.hoistingLimits` workspace (`nodeLinker: node-modules`)

See original GitHub issue

Self-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:closed
  • Created a year ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
bradleyayerscommented, Nov 3, 2022

Please provide reproduction steps

@larixer sure thing, I’ve added a Sherlock reproduction.

0reactions
larixercommented, Nov 9, 2022

@bradleyayers Great, thank you very much!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found