helia icon indicating copy to clipboard operation
helia copied to clipboard

No "exports" main defined in helia package

Open 9twy opened this issue 1 year ago • 7 comments

I am encountering the following error when trying to import the helia package in my TypeScript project:

Error: No "exports" main defined in C:\Users\saeed\type_script_projects\digital-asset-tracker\Backend\node_modules\helia\package.json
    at exportsNotFound (node:internal/modules/esm/resolve:296:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:586:13)
    at resolveExports (node:internal/modules/cjs/loader:640:36)
    at Function._findPath (node:internal/modules/cjs/loader:748:31)
    ...
    at Module.require (node:internal/modules/cjs/loader:134:12) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Steps to Reproduce

  1. Install the helia package using npm: npm install helia

Attempt to import and use helia in my project:

import { createHelia } from 'helia';

Run the project, which leads to the above error.

9twy avatar Nov 28 '24 21:11 9twy

what node version are you running?

ihlec avatar Nov 30 '24 08:11 ihlec

what node version are you running?

Node.js v22.11.0

9twy avatar Nov 30 '24 11:11 9twy

could you try importing any other package? Just to confirm that it is no general problem with your environment

ihlec avatar Nov 30 '24 14:11 ihlec

@9twy do you have a link to a repo that can reproduce this error?

SgtPooki avatar Dec 05 '24 14:12 SgtPooki

I had the same problem, I'm using node version 22.12.0

import { createHelia } from 'helia';

@Injectable()
export class DocumentService {
  private ipfsClient: any;

  constructor(private readonly prisma: PrismaService) {
    this.ipfsClient = createHelia();
  }

Luan-Web3 avatar Jan 28 '25 10:01 Luan-Web3

Can you please share a reproduction repo?

2color avatar Jan 29 '25 19:01 2color

@9twy do you have a link to a repo that can reproduce this error?

I have the same problem. now I'm using thridweb storage that doesn't have that problem.

you can find the problem on branch helia-bug repo https://github.com/Agentopians/AiVS-frontend

use npm start to reproduce it.

checked node 18 and 20 but didn't work.

saremeskandary avatar Feb 09 '25 03:02 saremeskandary

@saremeskandary your project uses ts-node which hasn't seen any updates for nearly two years so is quite out of date at this point.

Node.js has new type-stripping features which reduce the need for ts-node, though your project mixes require and import and also uses decorators so it's not a drop-in replacement.

@Luan-Web3 thanks for the code snippet. Unfortunately it's not runnable. I see you are also using decorators which implies there are some other code transformation tools being used since these are not part of the language. The problem likely lies with the interaction of build tools in your project setup but without seeing a full repo or example it's impossible to tell.

I'm going to close this because the OP has not provided any further information, but the problem is likely out of date or misconfigured build tools.

If in doubt, please try compiling your project and running the JavaScript it exports. If that works then you need to look at your project setup to figure out what is wrong.

achingbrain avatar Oct 09 '25 05:10 achingbrain