fix: run mklink through cmd so Windows npm install works - #7982
Merged
Conversation
npm install fails on Windows in postinstall with "mklink: command not found". mklink is a cmd.exe builtin rather than an executable, so the sh running this script cannot exec it, and every symlink the install needs is made this way. Routing it through cmd works. Verified on Windows 11 with git-bash: `mklink /J link src` reports command not found, `cmd //c mklink //J link src` reports "Junction created" and the junction resolves. Tested with the same relative paths symlink() passes, from a directory it has cd'd into. The doubled slashes are the usual MSYS escaping, and are safe here because this branch only runs when the OS was detected as cygwin or mingw.
code-asher
approved these changes
Sep 4, 2026
code-asher
left a comment
Member
There was a problem hiding this comment.
Thank you for finding this!
Actually, since this is for cygwin/wingw can we directly use ln?
Ah nevermind I tried in git bash and ln -s seems to just copy the file instead. 🤷
code-asher
enabled auto-merge (squash)
September 4, 2026 19:01
code-asher
disabled auto-merge
September 4, 2026 20:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
npm installon Windows (git-bash/MSYS) fails in postinstall withmklink: command not found. mklink is a cmd.exe builtin rather than an executable, so the sh running npm-postinstall.sh cannot exec it, and every symlink the install needs goes through this line.Routing it through
cmd //cfixes it. Verified on Windows 11:mklink /J link srcfrom sh reports command not found,cmd //c mklink //J link srcreports "Junction created" and a file reads correctly through the junction, using the same relative paths the symlink() call passes. The doubled slashes are MSYS argument escaping, safe here because this case only runs when the OS was detected as cygwin/mingw.One of the failures behind the recipes in #1397.