Home > @rushstack/node-core-library > FileSystem > createHardLink
Creates a hard link. The link target must be a file, not a folder. Behind the scenes it uses
static createHardLink(options: IFileSystemCreateLinkOptions): void;
For security reasons, Windows operating systems by default require administrator elevation to create symbolic links. As a result, on Windows it's generally recommended for Node.js tools to use hard links (for files) or NTFS directory junctions (for folders), since regular users are allowed to create them. Hard links and junctions are less vulnerable to symlink attacks because they cannot reference a network share, and their target must exist at the time of link creation. Non-Windows operating systems generally don't restrict symlink creation, and as such are more vulnerable to symlink attacks. Note that Windows can be configured to permit regular users to create symlinks, for example by enabling Windows 10 "developer mode."
A hard link requires the link source and target to both be located on same disk volume; if not, use a symbolic link instead.