I’m trying to run an express server from a WSL terminal in Visual Studio Code.
However, whenever, I run the command npm run dev
, I get the following error:
'\\wsl$\Ubuntu\home\simao\legalize-backend'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
I assume it has something to do with the path from windows to the folder in the WSL directory.
Which one is the right path format or what should I do to make this one valid?
Searching, I found that you can:
You can solve this problem (UNC Paths not supported) by mapping a normal drive letter to the path that has the UNC path.
But how do I map a normal drive letter to the path?
This happens because whatever tool you are using is trying to run commands via cmd.exe
and cmd.exe
does not understand UNC paths (those starting with \\...
rather than a drive letter). Mapping a UNC path to a drive will convert it to a drive letter path.
To map a WSL path to a Windows drive, run cmd.exe
(Command Line) and type the following command:
net use X: \\wsl$\Ubuntu\home\simao
Where X:
is the drive that will be created (you'll see it as network drive in e.g. My Computer) and \\wsl$\Ubuntu\home\simao
is the WSL path to the root of that drive. wsl$
is a special hostname that tells Windows to connect to WSL, Ubuntu
is a distribution name under WSL, and then finally \home\simao
is a path to a directory in the Ubuntu
distribution that should be mapped.