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

Bug: Error when running npx tsx ./scripts/githooks/check-localstorage-usage.ts on Windows #3423

Open
hustlernik opened this issue Jan 25, 2025 · 4 comments
Labels
bug Something isn't working unapproved

Comments

@hustlernik
Copy link
Contributor

Describe the bug

Running the command npx tsx ./scripts/githooks/check-localstorage-usage.ts on Windows produces an error:

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader.
This prevents the script from functioning as expected on Windows systems.

To Reproduce

Steps to reproduce the behavior:

Use Node.js version 18.17.1 on a Windows environment.
Run npx tsx ./scripts/githooks/check-localstorage-usage.ts.
Observe the error output in the terminal.

Expected behavior

The script should execute successfully on Windows, just as it does on other operating systems, without throwing any errors.

Actual behavior

The script fails with the following error:
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.

Screenshots

Image

Additional details

  1. This error might be related to the way absolute paths are handled on Windows.
  2. Potential workaround or fix could involve converting Windows paths to file:// URLs before passing them to the ESM loader.
  3. Ensure compatibility across all operating systems when addressing this issue.

Potential internship candidates

Please read this if you are planning to apply for a Palisadoes Foundation internship

@hustlernik hustlernik added the bug Something isn't working label Jan 25, 2025
@hustlernik hustlernik changed the title Bug: Error when running npx tsx ./scripts/githooks/check-localstorage-usage.ts on Windows Bug: Error when running npx tsx ./scripts/githooks/check-localstorage-usage.ts on Windows Jan 25, 2025
@yugal07
Copy link

yugal07 commented Jan 25, 2025

Instead of running the script with npx tsx, try using node directly:
node --loader tsx ./scripts/githooks/check-localstorage-usage.ts

@palisadoes
Copy link
Contributor

Instead of running the script with npx tsx, try using node directly: node --loader tsx ./scripts/githooks/check-localstorage-usage.ts

  1. That means the GitHub Action isn't compatible with all OSes. If contributors use the code there for evaluating their work, we'll continue to get the issue
    Image
  2. We ideally need a universal solution to the GitHub action

@abbi4code
Copy link
Contributor

Can we use a built-in Node.js tool (pathToFileURL) to change C:\path\to\file into file:///C:/path/to/file. This makes it work with ESM or we can also use unix style path this will work on all OS.

@palisadoes
Copy link
Contributor

It needs to work on all operating systems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unapproved
Projects
None yet
Development

No branches or pull requests

4 participants