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

tsx isn't being register correctly on Windows #1170

Closed
acerbisgianluca opened this issue Aug 18, 2024 · 1 comment · Fixed by #1171
Closed

tsx isn't being register correctly on Windows #1170

acerbisgianluca opened this issue Aug 18, 2024 · 1 comment · Fixed by #1171
Labels
bug Something isn't working windows Windows-only issue

Comments

@acerbisgianluca
Copy link

Describe the bug
I'm on Windows (Powershell) and I'm using tsx. When I run ./bin/dev.cmd before compiling the source code, it doesn't load any command from the src directory. Looking at the debug log, it isn't able to register tsx due to the following error:

  oclif:config:ts-path Determining path for D:\PROJECT_PATH\dist\commands +1ms
  oclif:config:ts-path registering tsx at D:\PROJECT_PATH +2ms
  oclif:config:ts-path tsx path: D:\PROJECT_PATH\node_modules\tsx\dist\esm\api\index.cjs +0ms
  oclif:config:ts-path 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 'd:'
  oclif:config:ts-path     at new NodeError (node:internal/errors:405:5)
  oclif:config:ts-path     at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:149:11)
  oclif:config:ts-path     at defaultLoad (node:internal/modules/esm/load:99:3)
  oclif:config:ts-path     at nextLoad (node:internal/modules/esm/hooks:864:28)
  oclif:config:ts-path     at load (file:///D:/PROJECT_PATH/node_modules/tsx/dist/esm/index.mjs?1723992192336:2:1768)
  oclif:config:ts-path     at nextLoad (node:internal/modules/esm/hooks:864:28)
  oclif:config:ts-path     at Hooks.load (node:internal/modules/esm/hooks:447:26)
  oclif:config:ts-path     at handleMessage (node:internal/modules/esm/worker:196:24)
  oclif:config:ts-path     at Immediate.checkForMessages (node:internal/modules/esm/worker:138:28)
  oclif:config:ts-path     at process.processImmediate (node:internal/timers:476:21) +3ms
  oclif:config:ts-path Could not find tsx. Skipping tsx registration for D:\PROJECT_PATH. +1ms

I tested with both a global tsx installation and a project one and I got the same error (with different tsxPath obv).

I manually added "file://" to this line before tsxPath and at this point it's able to correctly register tsx, but still it doesn't load the commands from the source folder even if the development flag is set to true when I call the execute function. Do I have to change the commands path in the package.json as well?

const {register} = await import(tsxPath)

To Reproduce
Steps to reproduce the behavior:

  1. Install tsx
  2. set DEBUG=*
  3. Use tsx instead of ts-node in ./bin/dev.cmd
  4. Run ./bin/dev.cmd
  5. Scroll up in the logs (be aware that I see the error posted above because I added a new debug line in the catch block to print the full error after the following line)
    debug(`Could not find tsx. Skipping tsx registration for ${root}.`)

Expected behavior
Firstly I expect tsx to be registered correctly on Windows as well, and secondly I expect ./bin/dev.cmd to load the commands from the src directory instead of the dist directory.

Environment (please complete the following information):

  • OS & version: Windows 10 build 19045.4780
  • Shell/terminal & version: Powershell 7.4.4

Additional details
Refers #966

Copy link

git2gus bot commented Aug 19, 2024

This issue has been linked to a new work item: W-16530475

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

Successfully merging a pull request may close this issue.

2 participants