Skip to content

Publish broken on Windows #38

Open
@IGx89

Description

@IGx89

Publishing (dev:publish) doesn't work on Windows (Windows 11, Node.js 22.15.1, compute-js-static-publish 7.0.1).

Steps to Reproduce

  1. Follow Quick Start instructions on Windows: https://github.com/fastly/compute-js-static-publish?tab=readme-ov-file#-quick-start

Expected Behavior

  • npm run dev:publish succeeds

Actual Behavior

  • npm run dev:publish produces the following error:
> [email protected] dev:publish
> npx @fastly/compute-js-static-publish publish-content --local

🧑‍💻Fastly Compute JavaScript Static Publisher (Management mode)
🚀 Publishing content...
  Working on local simulated KV Store...
❌ Can't load static-publish.rc.js
Run this from a compute-js-static-publish compute-js directory.
Unable to load ./static-publish.rc.js

Analysis

An error is being thrown in loadStaticPublisherRcFile when importing static-publish.rc.js. The catch block swallows the error, but here's what it is if I log it:

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:209:11)

import is unable to accept Windows absolute paths, which path.resolve produces on Windows. The solution is to use pathToFileURL(filePath).href to convert the absolute path to a file:// URL, or (better?) use path.posix.resolve instead of path.resolve.

This fix needs to be applied both to loadStaticPublisherRcFile and loadPublishContentConfigFile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions