[Feature]: Using node_modules
as symlink throws 'Error: ENOTDIR: not a directory, rmdir' with node-modules linker
#6415
Labels
Uh oh!
There was an error while loading. Please reload this page.
Self-service
Describe the bug
Due to CI (and other reasons) we need to symlink the
node_modules
folder to a persistent location thus reducing the time it takes for the linking step.Due to this, when we remove dependencies from a child workspace's
package.json
, which would result in an emptynode_modules
folder afteryarn install
, Yarn tries to delete the node_modules folder and throws:Since
node_modules
is now a symlink and not a directory, Yarn fails.To reproduce
Repo: https://github.com/hammad2506/yarn-symlinking-bug
git clone https://github.com/hammad2506/yarn-symlinking-bug.git
Let's assume the current project cwd is
/Users/hammadbalkhi/yarn-symlinking-bug
Then:
mkdir -p /Users/hammadbalkhi/yarn-symlinking-bug/my-workspace/backup
Yarn install
You will see both
yarn-symlinking-bug/my-workspace/backup
&yarn-symlinking-bug/my-workspace/node_modules
populated with the same contents."react": "17"
fromyarn-symlinking-bug/my-workspace/package.json
yarn install
You will see error:
Note: This only surfaces inside child workspaces as the
topLevelWorkspace
node_modules/
always contains a.yarn-state.yml
file even with no dependencies, so Yarn doesn't try to nuke thenode_modules
folder as it's not empty.Environment
System: OS: macOS 13.2.1 CPU: (10) x64 Apple M1 Pro Binaries: Node: 18.20.4 - /private/var/folders/pz/ktqbpyd903j9d6xy5sz0lj7r0000gn/T/xfs-810b17b9/node Yarn: 4.3.1 - /private/var/folders/pz/ktqbpyd903j9d6xy5sz0lj7r0000gn/T/xfs-810b17b9/yarn npm: 10.7.0 - ~/.nvm/versions/node/v18.20.4/bin/npm
Additional context
Ensure
nodeLinker: "node-modules"
is being usedThe text was updated successfully, but these errors were encountered: