Closed Schwartz10 closed 2 years ago
ipfs@0.63.x
is ESM-only, which means you can't use require
to load it, you have to use import
. Please see the upgrade guide.
Note if you're using TypeScript you'll need to specify "module": "ES2020"
and "target": "ES2015"
in your tsconfig.json
file.
@achingbrain I'm really stupid to understand how to solve this. Can you provide some examples on how to use your package now with other packages when bundling? version 56.0.2 seems to work well with everthing
async function loadIpfs() {
const { create } = await import('ipfs');
const ipfs = create({...});
return ipfs;
}
I am still getting the same error while trying the above code. I am using ipfs-http-client
and using NestJs. Can anyone please help me out?
Use a pre-ESM version of the ipfs-http-gateway
. This is difficult to find but apparently with v0.10.0
it became ESM only.
npm i -d --save-exact ipfs-http-gateway@v0.9
@kuzdogan
I am still getting the same error. I am using ipfs-http-client@v60
in NestJS. I would like to know how to solve that problem.
[ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in package.json
use type:module and use import {create} instead of requiring http client it , it worked
Version:
0.63.3
Platform:
Darwin MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64
Severity:
High - The main functionality of the application does not work, API breakage, repo format breakage, etc.
Description:
I've been trying to get a simple typescript nodejs project to import dependencies from
ipfs
on npm, but always results inThis sounds related to https://github.com/ipfs/js-ipfs/issues/4135 and https://discuss.ipfs.io/t/ts-ipfs-core-example-v0-15-0-causes-error-opposed-to-v0-14-0/14460
Steps to reproduce the error:
Clone this repo,
npm i
, andnpm start