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

Error [ERR_PACKAGE_PATH_NOT_EXPORTED] with programmatic use #362

Closed
antonplagemann opened this issue Dec 7, 2024 · 1 comment · Fixed by #363
Closed

Error [ERR_PACKAGE_PATH_NOT_EXPORTED] with programmatic use #362

antonplagemann opened this issue Dec 7, 2024 · 1 comment · Fixed by #363
Assignees
Labels
bug Something isn't working

Comments

@antonplagemann
Copy link

First, thanks for this great, yet simple library! I have been using it for some time and love how it 'just works' ❤️

I'm using ts-migrate-mongoose in programmatic mode (as described here), and starting from v3.8.4 I had an exception when trying to execute it:

node:internal/modules/run_main:123
    triggerUncaughtException(
    ^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './register' is not defined by "exports" in /my-project/node_modules/@swc-node/register/package.json imported from /my-project/node_modules/ts-migrate-mongoose/dist/esm/migrator.js
    at exportsNotFound (node:internal/modules/esm/resolve:296:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:586:13)
    at packageResolve (node:internal/modules/esm/resolve:822:14)
    at moduleResolve (node:internal/modules/esm/resolve:908:18)
    at defaultResolve (node:internal/modules/esm/resolve:1038:11)
    at nextResolve (node:internal/modules/esm/hooks:748:28)
    at resolveBase (file:///my-project/node_modules/tsx/dist/esm/index.mjs?1733557026686:2:3212)
    at resolveDirectory (file:///my-project/node_modules/tsx/dist/esm/index.mjs?1733557026686:2:3584)
    at resolveTsPaths (file:///my-project/node_modules/tsx/dist/esm/index.mjs?1733557026686:2:4073)
    at resolve (file:///my-project/node_modules/tsx/dist/esm/index.mjs?1733557026686:2:4447) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v22.8.0

I found it was caused by the following lines:

import { register } from '@swc-node/register/register'
register()

I could fix it changing it as follows:

-import { register } from '@swc-node/register/register';
-register();
+import '@swc-node/register';

If you can include this (or another fix) for the issue in the package that would be nice, so I can remove my patch file 😃 🙌

@ilovepixelart
Copy link
Owner

ilovepixelart commented Dec 7, 2024

Hello @antonplagemann thanks for the kind words, glad to hear that you found my packager useful, checked release notes looks like the issue you describing caused by switching to new swc register package. Strangely automated units did not catch this case, can you provide a sample repo with minimal setup where the case is reproducible?

But in any case changing one line is not an issue, just want to make sure such case is covered in the future
Just checked in my sample repos, seems it's workin here
https://github.com/ilovepixelart/ts-express-swc
https://github.com/ilovepixelart/ts-express-esbuild

@ilovepixelart ilovepixelart added the bug Something isn't working label Dec 7, 2024
@ilovepixelart ilovepixelart linked a pull request Dec 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants