Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Browserify Buffer is not defined #964

Closed
ondratra opened this issue Apr 5, 2019 · 2 comments
Closed

Browserify Buffer is not defined #964

ondratra opened this issue Apr 5, 2019 · 2 comments

Comments

@ondratra
Copy link

ondratra commented Apr 5, 2019

Hello,
I noticed on one of my project that current version of js-ipfs-http-client doesn't work in browser (using Browserify). The same error happens when I try to load example browserify project from https://github.com/ipfs/js-ipfs-http-client/tree/master/examples/bundle-browserify . After page load I get this error

bundle.js:26254 Uncaught ReferenceError: Buffer is not defined
    at Object.191../utils/default-config (bundle.js:26254)
    at o (bundle.js:1)
    at bundle.js:1
    at Object.<anonymous> (bundle.js:5)
    at Object.1.buffer (bundle.js:40)
    at o (bundle.js:1)
    at r (bundle.js:1)
    at bundle.js:1

That happens on this line

Object.assign(module.exports, { isIPFS, Buffer, CID, multiaddr, multibase, multicodec, multihash, PeerId, PeerInfo })

When I tried to include buffer package manually to the project it had no effect. Does anybody know what is wrong?

@alanshaw
Copy link
Contributor

alanshaw commented Apr 9, 2019

@dirkmc any chance you can port your fix for ipfs/js-ipfs#1969 over here?

@hugomrdias
Copy link
Contributor

@dirkmc can't we just explicitly require('buffer').Buffer instead of using the global buffer?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants