symlink
Create a symbolic link at path pointing to target. On Windows, type can be 'file', 'dir', or 'junction'; on Unix it is ignored.
Basic usage
import { symlink } from '@vooya/fs'
await symlink('./target.txt', './link.txt')
await symlink('./target-dir', './link-dir', 'dir') // Windows: directory symlinkMethods
symlink(target, path, type?)
Async. Returns Promise<void>.
| Argument | Type | Description |
|---|---|---|
target | string | Target path (stored in the link). |
path | string | Symlink path to create. |
type | ’file’ | ‘dir’ | ‘junction’ | Optional. Windows only; ignored on Unix. |
symlinkSync(target, path, type?)
Sync. Same arguments; throws on error (e.g. EEXIST if path exists).
Performance
Single syscall; on par with Node.js. See Benchmarks.
Notes
- Windows: Use
type: 'dir'for directory symlinks,'file'for file symlinks,'junction'for directory junctions when applicable. - Windows privileges: Creating symlinks can require developer mode or elevated privileges depending on the environment.
- Relative target: Stored as-is; resolution is at read time (e.g. via
readlink/realpath). - Known gap: Filesystem errors currently have Node-like messages, but do not expose Node-style
code,path,dest, andsyscallfields yet. - Current type gap: The TypeScript surface currently accepts any string for
type; Node documentsfile,dir, andjunction. - Unsupported Node path inputs:
Bufferpaths andURLpaths are not part of the current Vooya FSsymlinksurface.
Competitor measurements
See the full symlink comparison table for Node 22/24, peer libraries, sync/Promise modes, small and batch workloads, execution routes and measurement limits.
Last updated on