5

I'm making a tiny tool which is coding in Node.js and it would create file symlink on both Windows and OSX. However I get stuck at how to create symlink on Windows.

First, I tried fs.symlink and junction option, but junction only works for directory on Windows.

Secondly, by referring to Git Bash Shell fails to create symbolic links, I tried to directly call cmd <<< mklink SOURCE TARGET by using of shelljs.exec, it never returned, node console hung.

Thirdly, I created a shell script named 'symlink.sh', invoked this script by child_process.spawn, I got Error: spawn ENOENT.

Now I've no idea, how to solve it? Thanks

Community
  • 1
  • 1
fifth
  • 4,249
  • 9
  • 45
  • 62

1 Answers1

4

You can use lnk which is an OS-agnostic wrapper around the more specific tools.

kthy
  • 827
  • 10
  • 27