ipfs / js-ipfs-utils

IPFS utils
Other
23 stars 30 forks source link

unable to run in functions because of use of 'fs' #173

Closed robbiemu closed 2 years ago

robbiemu commented 2 years ago

I'm trying to use this in an azure function with a ipfs node hosted there as well.

A small issue, which is not related but just to note it, is that I had to set "esModuleInterop": true, in my tsconfig as the exports are old-style. But I'm sure that will change when it needs to, its not my issue.

I get this error:

 npm start

> fn-ipfs-broker@1.0.0 prestart
> npm run build

> fn-ipfs-broker@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

MacBook-Pro-2:fn-ipfs-broker robertotomas$ 

I think in this case we really don't need a local file. The filesize is limited to 100MiB, it can safely be processed in memory. I'm getting it from an HTTP multipart post using parse-multipart, so my buffer is the full in memory copy of the file in a buffer.

I can manually remove the fs from the d.ts file (replace with any) and get it to run. :)

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.

robbiemu commented 2 years ago

npm i -D ipfs-utils@9.0.2 fixes this for me