-
Notifications
You must be signed in to change notification settings - Fork 110
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]: No "exports" main defined in /home/ec2-user/helia/node_modules/helia/package.json #216
Comments
I got the same issue too |
Helia is an ESM-only module. You cannot use If you cannot use ESM for your project, you can use the dynamic import function to import it - please see the helia-cjs example for more. |
I’m not familiar with Nest. Can you share a link to your project or a repro repo please? |
Sorry, that's all I can share for you. |
But somehow it's work on Nextjs normal, but when public CID to network that not work like I hope (error uncaughtException: Error: PublishError.InsufficientPeers). So I move to Nestjs and surprise I get error like this issue. |
Looking at the default TypeScript settings created by It also uses jest and ts-jest which also appear to transpile to CJS by default so you will need to configure them to output ESM or to allow dynamic imports. |
@achingbrain I think my issue have connect this issue |
hi @achingbrain helia not support CJS? |
Helia supports CJS, please see the helia-cjs example. With the right config it also works with NestJS, see the helia-nestjs example. I see from your config above you are using Jest - here is the helia-jest example and the helia-jest-typescript example. All of these examples have one thing in common - they configure the tools being used to work with ESM so the correct method of loading modules occurs. Please check your config. If you still cannot solve this with the above examples as a reference, please create a small repo with a reproduction I can run, otherwise I cannot help you any further. |
Thank a lot for your help. I appreciated it. But still not work for me. I think the problem come from nx. Specific you can see issue from here: nrwl/nx#10296 |
I'm closing this as resolved because it seems like it's due to an issue with the nx system and ESM. Also of note, this is related to #190 |
yeah, but I wonder ask you: I see ipfs-http-client v56.0.3 support CJS, and I am using this version. But when I up to date the lastest version and I have the error like this issue. Why don't you continue support like ipfs-http-client v56.0.3 for Helia? |
Still have this issue in 2024. I'm unable to use Helia inside a hardhat project, unlike js-ipfs which always just worked. tweaking the tsconfig.json is just breaking other things. With the default hardhat scaffold's config, I get the no "exports" error for the Helia examples and I don't use CommonJS at all anywhere. |
I'm just trying to get the following code to run:
const { createHelia } = require('helia');
const { dagJson } = require('@helia/dag-json');
but it give the error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /home/ec2-user/helia/node_modules/helia/package.json
I am using nodeJS and express
The text was updated successfully, but these errors were encountered: