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

can not register @swc-node/register/esm with ERR_PACKAGE_PATH_NOT_EXPORTED error #704

Closed
item4 opened this issue Mar 23, 2023 · 2 comments
Closed

Comments

@item4
Copy link

item4 commented Mar 23, 2023

Reproduce

$ yarn node -r @swc-node/register/esm
yarn node v1.22.19
node:internal/modules/cjs/loader:571
      throw e;
      ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './esm' is not defined by "exports" in /home/item4/proj/blog/node_modules/@swc-node/register/package.json
    at new NodeError (node:internal/errors:399:5)
    at exportsNotFound (node:internal/modules/esm/resolve:361:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:641:13)
    at resolveExports (node:internal/modules/cjs/loader:565:36)
    at Module._findPath (node:internal/modules/cjs/loader:634:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at internalRequire (node:internal/modules/cjs/loader:174:19)
    at Module._preloadModules (node:internal/modules/cjs/loader:1431:5)
    at loadPreloadModules (node:internal/process/pre_execution:606:5) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v18.15.0
error Command failed.
Exit code: 1
Command: /home/item4/.nvm/versions/node/v18.15.0/bin/node
Arguments: -r @swc-node/register/esm
Directory: /home/item4/proj/blog
Output:

info Visit https://yarnpkg.com/en/docs/cli/node for documentation about this command.

Used package.json and tsconfig.json are here: https://github.com/item4/item4.github.io/tree/a302e5c08baaf26a1aea3c07d28465e1a7f8e4b3

@item4 item4 changed the title @swc-node/register/esm can not usable can not register @swc-node/register/esm with ERR_PACKAGE_PATH_NOT_EXPORTED error Mar 23, 2023
@Brooooooklyn
Copy link
Member

node --loader @swc-node/register/esm script.ts # for esm project

@abejfehr
Copy link

abejfehr commented Feb 6, 2024

I have a scenario where I need to register swc programmatically and can't change how node is invoked, is there any solution to this?

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