npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Bad combination: git for Windows +'s use of junctions

Copied from because this issue is terrible and needs to be fixed.

What’s going wrong?

If using npm link package-name on Windows, a junction will be created. If this is inside a git repository (with git set to ignore node_modules), performing git clean -xdf inside the repository (with a git for Windows installation), git will recurse into the junction and delete all content. See the relevant issues on the git for Windows repository: git-for-windows/git#607 git-for-windows/git#1270.

Steps to reproduce

Supporting information:

With recent versions of Windows 10, user of machine with Developer Mode enabled can create symlinks without elevated privileges. It would be nice if there was a flag or config option to configure what kind of link to create, as has been suggested before: #8520

Note: Git for Windows have previously concluded that junctions should be treated as hardlinks, not symlinks, and therefore that it is correct to recurse into the folder for cleaning. Npm seem to disagree.

Platform Info

git --version
git version
node --version
npm --version
Microsoft Windows [Version 10.0.17134.320]

It looks like occurs due to the gentle-fs project, also from npm. Symlinks look to be created here:

I believe all currently supported versions of Windows support symlinks. Could the above call simply be changed from junction to file?