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

Module not found: Error: Package path . is not exported from package #254

Closed
FabioPinheiro opened this issue Sep 5, 2023 · 3 comments
Closed

Comments

@FabioPinheiro
Copy link

Probably is a configuration problem in my project
But I get this error:
Module not found: Error: Package path . is not exported from package <somePath>/node_modules/helia (see exports field in <somePath>/node_modules/helia/package.json)

Is there a possibility this package is not in the standard format at the browsers expect webpack. (I'm using a relative complex pipeline so I'm unable to easy change it)

@FabioPinheiro
Copy link
Author

In the package.json I see

  "exports": {
    ".": {
      "types": "./dist/src/index.d.ts",
      "import": "./dist/src/index.js"
    }
  }

should I did look like this?

  "exports": {
    ".": {
      "require": "./dist/src/index.js",
      "types": "./dist/src/index.d.ts",
      "import": "./dist/src/index.js"
    }
  }

@FabioPinheiro
Copy link
Author

Oh I see #190
Hum seems I'm going to give up on the idea of playing with Helia for now. Since my pipeline is a bit inflexible

@achingbrain
Copy link
Member

"exports": {
    ".": {
      "require": "./dist/src/index.js",
      "types": "./dist/src/index.d.ts",
      "import": "./dist/src/index.js"
    }
  }

This will not work because ./dist/src/index.js is an ESM module and adding "require" to the exports map will cause it to be required, and you cannot require ESM modules.

You need to configure your project to use ESM, or you need to use dynamic imports but also ensure your project is not transpiling those to require behind your back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants