express-tsx-views icon indicating copy to clipboard operation
express-tsx-views copied to clipboard

On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

Open realJoshByrnes opened this issue 1 year ago • 1 comments

When I'm trying to render a view on Windows, I'm receiving the following error. I've tried using a file:// url in the viewsDirectory, but that itself presents a different error (because of path.resolve giving the wrong destination)

Error:

Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

Triggered by:

https://github.com/pmb0/express-tsx-views/blob/9f1a9d90b3714bc0a1c8eff9387ebd63c38bcb4e/src/react-view-engine.ts#L57C57-L57C57

Should filename be wrapped in a url.pathToFileURL(path) call?

realJoshByrnes avatar Dec 20 '23 10:12 realJoshByrnes

Just tested the same code using Debian (WSL) on the same computer. The code worked as expected.

realJoshByrnes avatar Dec 20 '23 10:12 realJoshByrnes