Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

ERR_PACKAGE_PATH_NOT_EXPORTED for ipfs-core #4125

Closed
ibaraki-douji opened this issue Jun 3, 2022 · 5 comments
Closed

ERR_PACKAGE_PATH_NOT_EXPORTED for ipfs-core #4125

ibaraki-douji opened this issue Jun 3, 2022 · 5 comments
Labels
need/triage Needs initial labeling and prioritization

Comments

@ibaraki-douji
Copy link

ibaraki-douji commented Jun 3, 2022

  • Version:
    ipfs-core: 0.15.1

  • Platform:
    Linux ae47c7682c9d 5.4.0-88-generic # 99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Severity:

Medium - A non-essential functionality does not work, performance issues, etc.

Description:

So i just setup the new ipfs project and when i was trying to start the program i got an error.

root@ae47c7682c9d:~/code# node ./lib/main.js
node:internal/modules/cjs/loader:488
      throw e;
      ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /root/code/node_modules/ipfs-core/package.json
    at new NodeError (node:internal/errors:372:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:472:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:693:7)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/root/code/lib/main.js:4:21) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
@ibaraki-douji ibaraki-douji added the need/triage Needs initial labeling and prioritization label Jun 3, 2022
@welcome
Copy link

welcome bot commented Jun 3, 2022

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@wouldgo
Copy link

wouldgo commented Jun 4, 2022

I resolved this loading the module via

const IPFS = await import('ipfs-core')

instead of requiring it.

@ibaraki-douji
Copy link
Author

ibaraki-douji commented Jun 5, 2022

Ok so with js it works fine but with typescript it keeps crashing ...
I will try to find for typescript. Thanks man

@ibaraki-douji
Copy link
Author

For typescript users :
To have this error removed you need to change compilerOptions.module to ESNext in the tsconfig.json

If you keep CommonJS it will transpile to a require() with a promise and it will give the error.

@MiqueiasGFernandes
Copy link

I resolved this loading the module via

const IPFS = await import('ipfs-core')

instead of requiring it.

@wouldgo After lost so many time searching a solution between it closed issues without reason, Your reply solved my problem, thanks for this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

3 participants