-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ERR_PACKAGE_PATH_NOT_EXPORTED with ipfs-http-client and typescript. Suggested fixes do not work. #4130
Comments
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
Finally, remember to use https://discuss.ipfs.io if you just need general support. |
Same error happens to me, but with the package
I am also using hardhat typescript project. Reproduction steps:
|
Please examine the code Instead use at least Better yet use |
Unfortunately with projects such as Hardhat (a pretty crucial platform in smart contract dev) having no plans to support ESM short/mid term NomicFoundation/hardhat#1808, it means we're stuck with older versions of IPFS if we want to use it with NFTs and other solidity-related projects. Changing module: and target: is not going to be an option for devs using projects such as Hardhat as their base environment. My understanding is there is cross-compatibility available between ES and commonjs and IPFS's own documentation even states this is possible (https://github.com/ipfs/js-ipfs/blob/master/docs/upgrading/v0.62-v0.63.md#esm) Therefore, there must be a way to solve this problem with an intermediary solution while other projects catch up. My problem is, I have implemented the documented solutions but nothing seems to work and I'm back to the original error no matter what I try. |
Dynamic imports are how you import ESM code in a CJS environment and is what the upgrade guide says to use. It's supported in all browsers and node 14+. If your TypeScript settings transpile the dynamic To stop that from happening you need |
Thanks for the suggestion. Unfortunately, I tried this but this breaks a whole bunch of import "side-effects" which Hardhat uses to modularize 3rd party functionality. And even if I resolve this, I then get other export problems so it seems to be a cascading problem. |
In accordance with ERR_PACKAGE_PATH_NOT_EXPORTED with ipfs-http-client and typescript. Suggested fixes do not work. ipfs#4130
Version:
57.0.1
Platform:
5.17.5-76051705-generic #202204271406
165150484022.04~63e51bd SMP PREEMPT Mon May 2 15: x86_64 x86_64 x86_64 GNU/LinuxSubsystem:
ipfs-http-client
Severity:
Medium
Description:
When attempting to import ipfs-http-client, the following error is thrown:
The problem appears to be related to the recent ES change. Changing module to "esnext" is not available because I am using Hardhat for the project's management and the HH devs have expressed no short term desire to address the issue.
I have applied the following update to try and load ipfs-http-client (https://github.com/ipfs/js-ipfs/blob/master/docs/upgrading/v0.62-v0.63.md#esm) and (#4125 (comment)) but without success:
but this gets me back to where I started, I.e. it is console.logging the error
ERR_PACKAGE_PATH_NOT_EXPORTED
.I have also looked at the dynamic imports documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_import and have implemented it in exactly the way documented but still no success.
I'm at an impasse. Am I missing something about dynamic imports for non-esm compliant environments?
Steps to reproduce the error:
Install ipfs-http-client to a node project using typescript:
Make sure tsconfig.json's compileOptions -> module setting is "commonjs":
Try and dynamically import ipfs-http-client:
The text was updated successfully, but these errors were encountered: