fifth
fifth

Reputation: 4349

how to create file symlink by using Nodejs on Windows?

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

Upvotes: 5

Views: 6573

Answers (1)

kthy
kthy

Reputation: 896

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

Upvotes: 4

Related Questions