Skip to content

@swc-node/register/register giving error 'is not defined by "exports"' #57536

@somewhatabstract

Description

@somewhatabstract

Version

20.19.0

Platform

Darwin <MyMachineName>.local 22.6.0 Darwin Kernel Version 22.6.0: Thu Sep  5 20:47:01 PDT 2024; root:xnu-8796.141.3.708.1~1/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

Write a little executable JS script for running non-ESM TypeScript files using the @swc-node/register/register import, and run it.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

With Node 20.18.x or using the --no-experimental-require-module with v20.19.0, this works.

The script should just run as it did before.With Node 20.18.x or using the --no-experimental-require-module with v20.19.0, this works.

What do you see instead?

With 20.19.0, it gives the error: Error: Package subpath './register' is not defined by "exports" error.

Additional information

It appears that the @swc-core/register package defines the register export as a require. I suspect that this is causing node to just ignore it when imported.

Metadata

Metadata

Assignees

No one assigned

    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