jungvonmatt / contentful-ssg

Export Contentful entries to filesystem (md|yaml) for static site generators (Hugo|Grow|...)
MIT License
14 stars 1 forks source link

[cssg-plugin-assets] pathToFileURL() issue on Windows #73

Open yannikrauter opened 8 months ago

yannikrauter commented 8 months ago

When working with contentful-ssg on macOS or Linux, everything works as expected. However, I have come across an error while trying to get my project to run on Windows.

I'm using contentful-ssg to pull my entries from Contentful, as well as the cssg-plugin-assets to also pull any assets. I believe the error I'm receiving is caused by the assets plugin and might have something to do with not using "url.pathToFileURL()", as described here.

After applying npx cssg fetch -v, the output log of my terminal looks like this (only when using Windows):

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: 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:'
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:239:11)
    at defaultLoad (node:internal/modules/esm/load:130:3)
    at ModuleLoader.load (node:internal/modules/esm/loader:403:13)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:56)
    at new ModuleJob (node:internal/modules/esm/module_job:65:26)
    at #createModuleJob (node:internal/modules/esm/loader:297:17)
    at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:254:34)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:235:17)
    at async ModuleLoader.import (node:internal/modules/esm/loader:322:23) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'

I have tried various node versions and fixes to circumvent the issue but unfortunately, to no avail.

Node version: v20.11.1

Hugo version: v0.122