Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. #123

Open
canserkanuren opened this issue Nov 25, 2024 · 5 comments
Assignees

Comments

@canserkanuren
Copy link

canserkanuren commented Nov 25, 2024

Hello,

I have been facing this issue for a few days and I have no way of resolving it...
My current setup is Windows (the following command works fine on Linux)
When running my action with npx local-action . src/main.ts .env, it ends up with the following error:

================================================================================
                                 Running Action
================================================================================

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^
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 nextLoad (node:internal/modules/esm/hooks:750:28)
    at load (file:///C:/Users/canse/gitstorage/github-repo-creator/node_modules/tsx/dist/esm/index.mjs?1732564389385:2:1768)
    at nextLoad (node:internal/modules/esm/hooks:750:28)
    at load (file:///C:/Users/canse/gitstorage/github-repo-creator/node_modules/quibble/lib/quibble.mjs:139:13)
    at nextLoad (node:internal/modules/esm/hooks:750:28)
    at Hooks.load (node:internal/modules/esm/hooks:383:26)
    at handleMessage (node:internal/modules/esm/worker:199:24)
    at Immediate.checkForMessages (node:internal/modules/esm/worker:141:28) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

Node.js v21.7.3

I created the action from the official typescript-action repository and only added a few lines of code in order to perform some tests for creating a new action.

The error is reproductible from this repository.
Simply clone it, run npm install and then run the local action with: npx local-action . src/main.ts .env.local
Thanks a lot in advance.

@ncalteen
Copy link
Collaborator

I think this is related to the bootstrap process that resolves the file paths before invoking the local-action logic. Let me break out my Windows box and test this out a bit further...

@ncalteen ncalteen self-assigned this Dec 11, 2024
@ncalteen
Copy link
Collaborator

Can you try with version 2.2.1 of local-action? This should be fixed in the latest patch.

@canserkanuren
Copy link
Author

Hello,
Still having the same issue, even with the 2.2.1 version...

@ncalteen
Copy link
Collaborator

Looks like it is because the action repo you linked is ESM. There's some additional steps involved to get ESM to work with local-action and GitHub Actions in general.

In the immediate term, I was able to get past the error by removing "type": "module" from package.json.

Longer term, I've submitted a PR to convert the TypeScript template to ESM. I also have an example of a working TypeScript action here you can reference here: https://github.com/issue-ops/parser

Let me know if that helps!

@canserkanuren
Copy link
Author

When removing "type": "module" from the package.json, I have the following error:
image
I added "type": "module" in order to remove the error above..
I'll wait for your PR to be merged, in order to see if it solves my issue.
Thanks a lot for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants