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

Cannot find module 'helia' from './src/Wrapper.ts' #149

Closed
T00rk opened this issue Jun 9, 2023 · 2 comments
Closed

Cannot find module 'helia' from './src/Wrapper.ts' #149

T00rk opened this issue Jun 9, 2023 · 2 comments
Labels
need/author-input Needs input from the original author

Comments

@T00rk
Copy link

T00rk commented Jun 9, 2023

import { createHelia } from 'helia';
import orbitdb from 'orbit-db';

export let helia;
export let orbit;

export const Connect = async() =>
{
  helia = await createHelia();
  orbit = await orbitdb.createInstance(helia);

  return [helia, orbit];
}

This code sample shows the error Cannot find module 'helia' from 'src/lib/OrbitWapper.ts'

My package.json has the correct dependencies

"dependencies": {
    "helia": "^1.3.1",
    "orbit-db": "^0.29.0"
},

EDIT

The issue is related to jest not finding module so I created a simple test project from the Create helia node example.
It fails with the following error

Error: No "exports" main defined in /mnt/storage/p2p/node_modules/blockstore-core/package.json
    at new NodeError (node:internal/errors:405:5)
    at exportsNotFound (node:internal/modules/esm/resolve:259:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:533:13)
    at resolveExports (node:internal/modules/cjs/loader:569:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:643:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1056:27)
    at Function.Module._load (node:internal/modules/cjs/loader:923:27)
    at Module.require (node:internal/modules/cjs/loader:1137:19)
    at require (node:internal/modules/helpers:121:18)
    at Object.<anonymous> (/mnt/storage/p2p/packages/test/test-orbit/src/index.ts:2:1)
@whizzzkid
Copy link
Contributor

Thanks for submitting this issue @T00rk, I was not able to reproduce this error. Just a note you're missing options.id that orbit-db is expecting, once you do that it seems to provide the instances you create.

Try it: https://replit.com/@whizzzkid/helia-149#index.js

If this still doesn't work for you, can you please create a repo/pr where I can try this?

@whizzzkid whizzzkid added the need/author-input Needs input from the original author label Jun 13, 2023
@T00rk
Copy link
Author

T00rk commented Jun 16, 2023

Thanks for your answer.
I've fixed it using this method:

export const Connect = async() =>
{
  const HELIA = await import('helia');
  const ORBIT = await import('orbit-db');

  helia = await HELIA.createHelia();
  orbit = await ORBIT.createInstance(helia);

  return [helia, orbit];
}

@T00rk T00rk closed this as completed Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/author-input Needs input from the original author
Projects
No open projects
Development

No branches or pull requests

2 participants