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

Runtime import error: ERR_PACKAGE_PATH_NOT_EXPORTED in NestJs #3191

Open
keyur555 opened this issue Feb 3, 2025 · 3 comments
Open

Runtime import error: ERR_PACKAGE_PATH_NOT_EXPORTED in NestJs #3191

keyur555 opened this issue Feb 3, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@keyur555
Copy link

keyur555 commented Feb 3, 2025

Describe the bug

When I use a package from the Eliza repository in a new Nestjs application, then I get this error.

The error example below happens for all imports, not only adapter of sqlite but also the core package.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/index.js' is not defined by "exports" in /app/node_modules/@elizaos/adapter-sqlite/package.json

at new NodeError (node:internal/errors:405:5)

at exportsNotFound (node:internal/modules/esm/resolve:366:10)

at packageExportsResolve (node:internal/modules/esm/resolve:713:9)

To Reproduce

Expected behavior

No error. Imports should work.

Additional context

I try different tsconfig configuration with "moduleResolution": "node" and other, but the error persists. If I delete the "export" content from all Eliza packages locally inside node_modules, then it works locally.

@keyur555 keyur555 added the bug Something isn't working label Feb 3, 2025
Copy link
Contributor

github-actions bot commented Feb 3, 2025

Hello @keyur555! Welcome to the elizaOS community. Thank you for opening your first issue; we appreciate your contribution. You are now an elizaOS contributor!

@jmderby
Copy link

jmderby commented Feb 7, 2025

+1 for me too. Happening for me using express instead of nest, looking into a solution...

@jmderby
Copy link

jmderby commented Feb 7, 2025

I got a fix for this, i'm running @elizaos/core so i'm not certain it will work for adapter-sqlite. I'm assuming it will

  1. Create a patch for @elizaos/core

    pnpm patch @elizaos/[email protected]
  2. Update the package.json in the patched directory

    • Navigate to the generated patch directory
    • Update the exports field in package.json to include the following:
    "exports": {
        "./package.json": "./package.json",
        ".": {
            "types": "./dist/index.d.ts",
            "default": "./dist/index.js",
            "import": "./dist/index.js"
        },
        "./source": "./src/index.ts"
    }
  3. Save and apply the patch

    pnpm patch-commit <path-to-patch-directory>
  4. Add sharp as a dependency

    pnpm add sharp

    Or add it manually to your project's package.json:

    {
      "dependencies": {
        "sharp": "latest"
      }
    }

Why I think this Works

  • The updated exports field properly defines the module entry points
  • Adding sharp as a dependency satisfies a required peer dependency
  • The patch ensures these changes persist across installations

Note

Make sure to replace 0.25.6-alpha.1 with the version of @elizaos/core you're using if different.

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

No branches or pull requests

2 participants