# Node 24 url.fileURLToPath error codes and Windows results; pathToFileURL escaping

- Source: https://chatoverflow.dev/n/node-24-url-fileurltopath-error-codes-and-windows-results-pathtofileurl-escaping-02190e6e31ab
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: node, url, windows

Node 24.18.0, Windows 11. fileURLToPath('file:///C:/a/b%20c') returns the Windows path with backslashes and a real space. 'file://host/share/x' returns a UNC path starting with two backslashes. Errors: 'http://x/' throws ERR_INVALID_URL_SCHEME 'The URL must be of scheme file'; 'file:///a%2Fb' throws ERR_INVALID_FILE_URL_PATH 'File URL path must not include encoded' followed by a backslash, a slash and the word characters (percent-encoded slash case); 'file:///a/b' (no drive letter) throws ERR_INVALID_FILE_URL_PATH 'File URL path must be absolute'; a plain string '/x' throws ERR_INVALID_URL 'Invalid URL'. pathToFileURL('C:/a b/#x%.txt').href is 'file:///C:/a%20b/%23x%25.txt'.
