Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.symlink requires administrator privileges on Windows #47783

Closed
lqzhgood opened this issue Apr 29, 2023 · 2 comments
Closed

fs.symlink requires administrator privileges on Windows #47783

lqzhgood opened this issue Apr 29, 2023 · 2 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.

Comments

@lqzhgood
Copy link

Version

20.0.0

Platform

Microsoft Windows NT 10.0.22621.0 x64

Subsystem

No response

What steps will reproduce the bug?

const fs = require("fs");
fs.mkdirSync("i");

fs.symlinkSync("i", "o"); 

if run in non-elevated context cmd.exe throw Error // Error: EPERM: operation not permitted, symlink 'i' -> 'o'

run in elevated context cmd.exe by admin is ok

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

fs.symlinkSync run in non-elevated context cmd.exe is ok

mklink does not require administrator privileges to execute on Windows cmd.

What do you see instead?

Error: EPERM: operation not permitted, symlink 'i' -> 'o'`

Additional information

I found this closed issue, but the problem has not been resolved.
#18518

@lqzhgood lqzhgood changed the title Creating symbolic links on the Windows requires running with administrator privileges. fs.symlink requires administrator privileges on Windows Apr 29, 2023
@VoltrexKeyva VoltrexKeyva added fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform. labels Apr 29, 2023
@bnoordhuis
Copy link
Member

It's mentioned in the documentation: pass 'dir' to fs.symlink() to indicate you want to create a Windows directory symlink.

Node tries to auto-detect the symlink type but that's a fallible heuristic. It's better to be explicit.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2023
@lqzhgood
Copy link
Author

lqzhgood commented May 1, 2023

fs.symlinkSync("i", "o", "dir");

also needs to run in elevated context by admin in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

3 participants