Closed rrubio closed 2 years ago
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:
Finally, remember to use https://discuss.ipfs.io if you just need general support.
The latest ipfs-http-client
is ESM only. This means you cannot use require
to load the module, you must use import
.
Please see the upgrade guide.
Hey! I am using import { create } from "ipfs-http-client";
in my project, and I still get this error, any idea why that could be?
It seems to be due to the fact that I'm using it in a HardHat task, and that is not an ESM, even though I am using import
for everything.
I'm seeing the same thing. I'm using es6 import and getting that same error: import { create } from 'ipfs-http-client';
No "exports" main defined in ...\node_modules\ipfs-http-client\package.json
If you're doing something like using typescript with import
in your .ts
files and still seeing No "exports" main defined in
, chances are your tsc config is set to output CJS. It needs to be ESM - set this using the "module" key in tsconfig.json
- it should be "es2020"
at least.
Yes, that is the problem I figured out just recently. I'm using NestJS which doesn't support ESM modules right now. Also, doing dynamic imports with const { create } = await import('ipfs-http-client')
isn't working for me either.
Hey! I am using
import { create } from "ipfs-http-client";
in my project, and I still get this error, any idea why that could be?It seems to be due to the fact that I'm using it in a HardHat task, and that is not an ESM, even though I am using
import
for everything.
had same problem with HH right now, but i used that module in the past. Resolved with pnpm i ipfs-http-client@56.0.2
pnpm i ipfs-http-client@56.0.2
This solved our problem when using nestJs, thanks!
Hey! I am using
import { create } from "ipfs-http-client";
in my project, and I still get this error, any idea why that could be? It seems to be due to the fact that I'm using it in a HardHat task, and that is not an ESM, even though I am usingimport
for everything.had same problem with HH right now, but i used that module in the past. Resolved with pnpm i ipfs-http-client@56.0.2
Downgrading to version 56.x.x works for me.
Same here. Downgrading to ipfs-http-client@56.0.2 worked for me. Will there be a fix for this in the higher versions?
Confirm, was having this problem until I did downgrade to 56.0.2 and it worked :) 👍🏼
I'm also hitting this when using ipfs-http-client in Nest, with typescript and only importing using import { create } from 'ipfs-http-client';
.
Please see this comment https://github.com/ipfs/js-ipfs/issues/4180#issuecomment-1319951128
@KKRAKOVIA Thank you. Issue solved. Great!
Downgrading to v56.0.2 and with this code:
let ipfs: IPFSHTTPClient = create({
host: "ipfs.infura.io",
port: 5001,
protocol: "https",
headers: {
authorization: this.auth
}
});
ipfs.add("test").then((res)=>{
resolve(res.cid.toString());
})
I have this error:
TypeError: RequestInit: duplex option is required when sending a body.
It seem to be a node fetch error, how to solve?
@francesco-gaglione I am also getting the same error... Were you able to resolve it....?
I'm getting the same error
Same here and the only way I found to fix it was to modify the source ->
Hey! I am using
import { create } from "ipfs-http-client";
in my project, and I still get this error, any idea why that could be? It seems to be due to the fact that I'm using it in a HardHat task, and that is not an ESM, even though I am usingimport
for everything.had same problem with HH right now, but i used that module in the past. Resolved with pnpm i ipfs-http-client@56.0.2
Resolved my problem. Tks !!!
IPFS Version -
NodeJS Version -
NPM Version -
OS -
Error occurs when i run my script like so "node client.js" -
` const IpfsClient = require('ipfs-http-client') const OrbitDB = require('orbit-db')
const ipfs = IpfsClient('localhost', '5001')
(async () => {
})() `
I have tried adding the following to "node_modules -> ipfs-http-client -> package.json" with no luck -
"exports": { ".": { "import": "./src/index.js" }, "./client": "./client.js"
Please note - i get the exact same error when using "ipfs".