Closed dekadentno closed 3 years ago
You may need import { Buffer } from "buffer/"
(note the slash) rather than import { Buffer } from "buffer"
, in order to import the buffer
npm package rather than the shim that the bundler injects, which may be an older version of buffer
.
Thank you for your answer. I managed to do that in my codesandbox above, but writeBigUInt64BE
is still undefined in my local vue project.
Steps to reproduce error:
git clone https://github.com/dekadentno/buffer-test
cd buffer-test
npm i
npm run serve
I know this may not be the place to ask this, but I hope you may know the answer. I also assume this may be a webpack/babel issue, but I cannot be certain.
The issue was in the import. Even import { Buffer } from "buffer/" // notice the slash
didn't help me, I had to import it this way import { Buffer } from 'buffer/index.js'
because it was picking up node_modules/node-libs-browser/node_modules/buffer/index.js
instead of node_modules/buffer/index.js
.
I don't know if it should be noted in the docs and if anyone had a similar issue.
I am trying to access
writeBigUInt64BE
like in the codesandbox below: https://codesandbox.io/s/stoic-bohr-bnsirbut the error states that
although it is exported as seen here: https://github1s.com/feross/buffer/blob/HEAD/index.js#L1542-L1543 Functions like
writeIntLE
are exported in the same way and they can be accessed.Note:
typeof BigInt
returnsfunction
in my browser.