ipfs / js-ipfs

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

ReferenceError: global is not defined using "await ipfs.files.write('/' + file.name, file, { create: true })" in browser #4248

Closed scenaristeur closed 1 year ago

scenaristeur commented 1 year ago

i got this message using await ipfs.files.write('/' + file.name, file, { create: true }) in browser as mentionned in https://proto.school/mutable-file-system/04

Uncaught (in promise) ReferenceError: global is not defined
    toAsyncIterator to-async-iterator.js:44
    mfsWrite write.js:99

a workaround that can help is if (typeof window !== "undefined") window.global = window; as in this file https://github.com/scenaristeur/browser-vue/blob/64f58a9843b26b9794c370cd163d586369b67437/src/plugins/vue-ipfs.js#L12

achingbrain commented 1 year ago

Do you see the problem on protoschool or your own project?

github-actions[bot] commented 1 year ago

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

scenaristeur commented 1 year ago

Hi, in my own project, code is up, root of project with demo here https://github.com/scenaristeur/browser-vue

Based on https://github.com/ipfs-examples/js-ipfs-examples/tree/master/examples/browser-vue

My goal is to build something like a decentralized filesystem Screenshot_20221223-100625_Chrome

github-actions[bot] commented 1 year ago

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it is missing author input.