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?]: node-modules - Dependency with different major version in nested workspace not installed

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

I have two nested packages. The outer one depends on ESLint 7, the inner one on ESLint 8. Only ESLint 7 is installed.

To reproduce

const { writeFile } = require("fs").promises;

await packageJson({
  private: true,
  dependencies: {
    eslint: "^7.0.0"
  }
},{ cwd: "workspace" })

await packageJson({
  private: true,
  dependencies: {
    eslint: "8.0.0-beta.2"
  }
},{ cwd: "workspace/nested" })

await writeFile(".yarnrc.yml", `nodeLinker: node-modules`);
await writeFile("workspace/nested/index.js", `module.exports = require("eslint/package.json").version`);

await packageJsonAndInstall({
  workspaces: ["workspace", "workspace/nested"]
});

const version = await node("workspace/nested/index.js");

expect(version).toBe("8.0.0-beta.2");

If this sherlock reproduction doesn’t work, you can clone this branch: https://github.com/nicolo-ribaudo/babel/tree/yarn-bug-missing-dep. The last commit shows the package necessary to introduce the bug; you can run node eslint/babel-eslint-parser/test/eslint-8/index.js and it should print 8.0.0-beta.2.

Environment

System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 16.8.0 - /tmp/xfs-cc5b8bc4/node
    Yarn: 2.4.1-git.20210125.0f31e6910 - /tmp/xfs-cc5b8bc4/yarn
    npm: 7.21.1 - ~/.npm-global/bin/npm

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
larixercommented, Sep 14, 2021

@nicolo-ribaudo Just a heads up, I’ve took a stab to fix this issue at #3438, checked your example and it works for me now. Gotta add integration tests to the PR to prevent future regressions in the following days.

0reactions
larixercommented, Sep 13, 2021

Seems to be a valid issue; the workspace/nested copy of eslint shouldn’t be hoisted into its parent workspace (probably happens because of having a workspace inside a workspace).

The problem is actually different. The workspaces/nested copy is hoisted to the top-level, not to the parent workspace. The eslint copy in the parent workspace is correct. Looking…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I override nested NPM dependency versions?
When I do this, only the grunt-contrib-connect dependency and its children are installed. All my other dependencies in package.json are not installed. –...
Read more >
npm-link
First, npm link in a package folder with no arguments will create a symlink in the global ... Only install direct dependencies in...
Read more >
A story of how we migrated to pnpm - ‹div›RIOTS
We recently switched to pnpm, here's why and how.
Read more >
The Case for Monorepos: A sane Workspace Setup (Part 2)
Used, but not installed dependencies: the opposite could be the case ... other packages in your monorepo (as direct or nested dependency).
Read more >
Symlinked `node_modules` structure - PNPM
pnpm's node_modules layout uses symbolic links to create a nested structure of dependencies. Every file of every package inside node_modules is a hard...
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