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

swc-node/register make follow-on --import resolve to wrong path #846

Open
hax opened this issue Aug 22, 2024 · 1 comment
Open

swc-node/register make follow-on --import resolve to wrong path #846

hax opened this issue Aug 22, 2024 · 1 comment
Assignees

Comments

@hax
Copy link

hax commented Aug 22, 2024

Assume I have test.js, I can run node --import ./test1.js well.

But node --import @swc-node/register/esm-register --import ./test1.js fail:

node:internal/modules/run_main:129
    triggerUncaughtException(
    ^
Error: All of the aliased extensions are not found for /hax/test1.js: ./test1.js cannot be resolved in file:///hax/x/
    at resolve (file:///hax/x/node_modules/@swc-node/register/esm/esm.mjs:157:15)
    at async nextResolve (node:internal/modules/esm/hooks:866:22)
    at async Hooks.resolve (node:internal/modules/esm/hooks:304:24)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18)

Node.js v20.16.0

I notice the dir seems become parent dir, and found that node --import @swc-node/register/esm-register/esm-register --import ./x/test1.js works.

Note, version 1.10.0 is ok (though not support --import ./test.ts). It seems become broken from 1.10.1 .

@hax hax changed the title swc-node/register resolve to wrong path swc-node/register make follow-on --import resolve to wrong path Aug 22, 2024
@benzittlau
Copy link

benzittlau commented Aug 26, 2024

I am getting this same error when attempting to import bignumber.js using swc-node/register/esm which I wasn't seeing previously utilizing ts-node. I've created a repo that reproduces the issue here:

https://github.com/benzittlau/swc-import-error-reproduction-repo

It seems like it may be related to it needing to be in a yarn workspace as I wasn't able to reproduce the issue without the yarn workspace hoisting involved:

Error: All of the aliased extensions are not found for /.../swc-import-bug/package/node_modules/bignumber.js: bignumber.js cannot be resolved in file:///.../swc-import-bug/package/src/index.ts
    at resolve (file:///.../swc-import-bug/node_modules/@swc-node/register/esm/esm.mjs:157:15)
    at async nextResolve (node:internal/modules/esm/hooks:865:22)
    at async Hooks.resolve (node:internal/modules/esm/hooks:303:24)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18)

@Brooooooklyn Brooooooklyn self-assigned this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants