The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Bad combination: git for Windows + npm.link's use of junctions
Copied from https://github.com/npm/npm/issues/19091 because this issue is terrible and needs to be fixed.
What’s going wrong?
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
- Install git for Windows.
- Link a package into an install in a repository (
npm link package-namein repository).
git clean -xdfin repository.
- The files in the
package-nameinstall are now gone.
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.
git version 2.19.1.windows.1
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: https://github.com/npm/gentle-fs/blob/latest/lib/link.js#L62
I believe all currently supported versions of Windows support symlinks. Could the above call simply be changed from