WSL Pitfall - Disk Format Issue with Symlinks
TL;DR
If you encounter Error: EPERM: operation not permitted, symlink or any other symlink-related errors in WSL, first check whether the disk format is NTFS or ReFS.
As usual, I was writing my annual year-in-review blog post on New Year’s Eve and ran npm install, only to be greeted with the following error:
1 | npm ERR! code EPERM |
I was completely baffled. I had been using WSL for several years and had never run into this problem before. After searching around on Google, I found many articles, but the most helpful solution came from https://github.com/MicrosoftDocs/WSL/issues/26#issuecomment-206991754
The suggested fix was as follows:
Using this I’ve had some luck installing some npm modules, but it still does have issues with permission errors whenever npm tries to rename a file.
INSTALL GLOBAL NPM PACKAGES
npm config set unsafe-perm true
CLEAN CACHE
npm cache clean (Note: newer versions of npm require npm cache verify)
BYPASS SYMLINK ISSUES
npm install --no-bin-links
After running these steps, npm install did succeed.

Just when you thought you had solved the problem, reality had other plans.

I was stumped again, and in my confusion I tried a few things that turned out to be a waste of time:
- Reinstalled WSL — problem persisted.
- Reinstalled the OS — problem still persisted.
Then it suddenly hit me: this drive had previously been used as an external/portable drive. Could the file system format be wrong?

At this point, I finally spotted a glimmer of hope.
I then checked the WSL documentation (https://docs.microsoft.com/en-us/archive/blogs/wsl/wsl-file-system-support#drvfs) and found the following description — pay attention to the bolded sentence:
To facilitate interoperability with Windows, WSL uses the DrvFs file system. WSL automatically mounts all fixed drives with supported file systems under /mnt, such as /mnt/c, /mnt/d, etc. Currently, only NTFS and ReFS volumes are supported.
I then reformatted the drive as NTFS and tried again. Everything worked perfectly.