percy / cli

The Percy CLI is used to interact with, and upload snapshots to, percy.io via the command line.
https://docs.percy.io/docs/cli-overview
71 stars 45 forks source link

[ERR_UNSUPPORTED_ESM_URL_SCHEME]: when running on Windows #864

Closed appMatthewH closed 2 years ago

appMatthewH commented 2 years ago

The problem

When performing a snapshot run, I receive the following error. This happened after updating from percy/cli-beta.076 to percy/cli.1.0.3

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

This is only happening in my Windows environment. When running on Linux or Mac, i have not experienced this.

Environment

Debug logs

[percy:config] Config file not found (0ms)
[percy:cli] Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at new NodeError (node:internal/errors:371:5)
    at defaultResolve (node:internal/modules/esm/resolve:1016:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ESMLoader.import (node:internal/modules/esm/loader:276:22)
    at importModuleDynamically (node:internal/modules/esm/translators:111:35)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
    at loadSnapshotFile (file:///C:/Users/Appnovation/Documents/Repositories/qa-scripts/node_modules/@percy/cli-snapshot/dist/snapshot.js:153:27)
    at file:///C:/Users/Appnovation/Documents/Repositories/qa-scripts/node_modules/@percy/cli-snapshot/dist/snapshot.js:87:29
    at AsyncGenerator.next (<anonymous>) (24ms)
Robdel12 commented 2 years ago

Hey @appMatthewH! Thanks for the issue. Can you share the full non-edited logs (with the invocation)? Also maybe give an idea what the snapshot file looks like?

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 28 days with no activity.

christjt commented 2 years ago

Hey @Robdel12, just want to pitch in here as I hit this error today on v1.10.0 of the CLI, also on Windows. The reason this is happening is in https://github.com/percy/cli/blob/master/packages/cli-snapshot/src/snapshot.js#L134. path.resolve only returns an absolute path (not a URL) on Windows. Prefixing it with file:// fixes the issue.

wwilsman commented 2 years ago

Hey @christjt, thanks for the clarification on this issue around where its happening!

I just pushed #1055 to address this, which will go out with the next release. 👍