[Enhancement]: yarn on Windows with nodeLinker set to node-modules creates symlinks as absolute paths in node_modules folder
See original GitHub issueSelf-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 tonode-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:
- Created a year ago
- Comments:7 (7 by maintainers)
master
, I’ll backport it if needed.Nothing else needs to be bumped in this case 👍
Bingo! https://github.com/yarnpkg/berry/blob/77e525a7e33581b38c86bfb80da075ce84f9a9f6/packages/plugin-nm/sources/NodeModulesLinker.ts#L677