Skip to content

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

Description

@hax

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 .

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions