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.

[Enhancement]: yarn on Windows with nodeLinker set to node-modules creates symlinks as absolute paths in node_modules folder

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

Yarn 3.2.4 Windows 10 Node 18.x Docker node-linker

Running ‘yarn install’ on multiple workspaces that use ‘portal:’ or ‘workspace:’ to reference other workspaces results in symlinks in the top level node_modules that are absolute paths.

Running ‘yarn install’ on the same monorepo creates symlinks with relative paths, as expected.

The issue is with mounting the filesystem into Docker containers for running consistent builds.

The absolute paths are broken in Docker because we mount just the project directory as a Docker volume, not an entire hard drive.

Relative paths, as created in Yarn on Linux work correctly,

E.g.

Partial listing of node_modules when yarn install is run on Linux:

common-dev-tools -> ../common/dev-tools
common-front -> ../common/front
common-front-and-back -> ../common/front-and-back

vs. exact same repo, but yarn install run from WIndows:

common-dev-tools -> C:\Users\jeff.wishnie\source\repos\xxx\common\dev-tools\     
common-front -> C:\Users\jeff.wishnie\source\repos\xxx\common\front\ 
common-front-and-back -> C:\Users\jeff.wishnie\source\repos\xx\common\front-and-back\

To reproduce

// sorry, this issue is only windows, so sherlock can’t be used. Instead here are high-level reproduction steps

  • Create a new project: yarn init -2
  • edit .yarnrc.yml to set nodeLiker to node-modules
  • Create two workspaces: packages/a; packages/b
  • Edit package json to add: workspaces: packages/*
  • Add package a as a dependency in package b:
    • (from package/b): yarn add a@“workspace:*”

From WINDOWS run yarn install NOTICE: the link created in node_modules is absolute not relative

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
  Binaries:
    Node: 18.11.0 - 
    Yarn: 3.2.4
    npm: 8.19.2

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
merceyzcommented, Oct 21, 2022

Before I make a PR, question: should it make the PR to master or to a 3.x branch?

master, I’ll backport it if needed.

Changes are exclusive to nm-linker plugin, so just bumped plugin-nm and cli . not sure if everything that depends on CLI (other plugins) needs bumping as well?

Nothing else needs to be bumped in this case 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] allow node_modules to be a symbolic link #2258 - GitHub
I'd be willing to implement a fix Describe the bug For every other directory that yarn wants to write, a symbolic link to...
Read more >
yarn link
This will create a symlink named react-relay/node_modules/react that links to your local copy of the react project. Links are registered in ~/.config/yarn/link ...
Read more >
Advanced package manager features for npm, Yarn, and pnpm
The traditional dependency resolution strategy to flatten node_modules folders leads to several different issues: Modules can (accidentally) ...
Read more >
Migrating to Yarn 2 - Heroku Dev Center
The team has created a “zero installs” package manager, which means users may use ... There's no need to specify the node_modules directory....
Read more >
How to install package with local path by Yarn? It couldn't find ...
For yarn version < 2.x. Yarn requires prefix file: for local packages. For relative path: yarn add file:./../your-project. For absolute path
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