Skip to content

fs.symlink can’t create directory symlinks on Windows #18518

Closed
@chris-morgan

Description

@chris-morgan
  • Version: v8.9.4
  • Platform: Windows 10, 64-bit, build 17083 (Windows Insider Preview). In developer mode (so normal users can create symlinks).
  • Subsystem: fs

Using fs.symlinkSync( x, y, 'dir' ) to create a directory symlink is failing (EPERM: operation not permitted), while mklink /d is able to make the symlink.

Simplest example to demonstrate the issue:

C:\Users\me\AppData\Local\Temp>node
> require('fs').symlinkSync('abcdef', 'ghijkl', 'dir')
Error: EPERM: operation not permitted, symlink 'abcdef' -> 'C:\Users\me\AppData\Local\Temp\ghijkl'
    at Object.fs.symlinkSync (fs.js:1014:18)

File symlinks are fine; it’s only directory symlinks that are failing. It doesn’t matter whether the target path exists or not, it fails with the same EPERM error.

Meanwhile,

C:\Users\me\AppData\Local\Temp>mklink /d ghijkl abcdef
symbolic link created for ghijkl <<===>> abcdef

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions