ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

error importing ipfs-core from TypeScript "Cannot find namespace 'fs'." #4080

Closed gobengo closed 2 years ago

gobengo commented 2 years ago

Severity: High (library not usable in this context)

Description:

Note: this issue is similar to https://github.com/ipfs/js-ipfs/issues/4029 , but a different ts error so not the same

Steps to reproduce the error:

bengo@MacBook-Pro ~/dev/ipld-experiments/ipld-web3-storage ⚡  npm run build                                         

> ipld-web3-storage@1.0.0 build
> tsc

node_modules/ipfs-utils/dist/src/files/glob-source.d.ts:10:14 - error TS2503: Cannot find namespace 'fs'.

10     content: fs.ReadStream | undefined;
                ~~

Found 1 error in node_modules/ipfs-utils/dist/src/files/glob-source.d.ts:10

I tried clonging js-ipfs repo myself to npm link and find a fix, but npm install on my m1 mac fails because npm ERR! response status 404 Not Found on https://node-webrtc.s3.amazonaws.com/wrtc/v0.4.7/Release/darwin-arm64.tar.gz which is https://github.com/node-webrtc/node-webrtc/issues/680

welcome[bot] commented 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.

gobengo commented 2 years ago

I was able to recreate this issue only against ipfs-utils, not ipfs-core. So I will open an issue/PR there.

The good news is I think I also have a patch for ipfs-utils that will fix it (based on npm link testing)

callezenwaka commented 2 years ago

Hi, Any solution to this yet? Ran into same issue.

jamesrwaugh commented 2 years ago

@callezenwaka For now, adding "skipLibCheck": true to tsconfig compilerOptions worked for me. As per https://github.com/ipfs/js-ipfs/issues/4029#issuecomment-1023028735

gobengo commented 2 years ago

reopening to track ipfs-core upgrading to the fixed ipfs-utils@9.0.6 (if needed)